Reputation: 39
I'm trying this regex, but along with uppercase it matches lowercase somehow.
preg_match("/^([A-Z&\s\']+),/i", $line, $match);
Any ideas where is my mistake? Thanks!
Upvotes: 1
Views: 668
Reputation: 626903
You need to remove the case insensitive modifier /i
:
preg_match('/^([A-Z&\s\']+),/', $line, $match);
^
Otherwise, the [A-Z]
range matches both [a-z]
and [A-Z]
ranges.
Pattern details:
^
- start of string([A-Z&\s\']+)
- Group 1 capturing 1 or more uppercase ASCII letters (A-Z
), a literal &
, whitespace (\s
) or a literal '
,
- a commaUpvotes: 1