Reputation: 407
Example:
my $cities = qr/San Francisco|Los Angeles/;
The scalar $cities
will match San Francisco
and Los Angeles
but will not match SAN FRANCISCO
, LOS ANGELES
, san francisco
, or los angeles
. Is there a way to make these variables case insensitive without having to create a capitalized version of them?
Upvotes: 3
Views: 2947
Reputation: 93666
It's not that you want to make the scalar $cities
case-insensitive, but the regular expression it is referencing. Use the /i
modifier.
my $cities = qr/San Fransisco|Los Angeles/i;
You may find it useful to read the Perl regular expression tutorial: perldoc perlretut
.
Upvotes: 8
Reputation: 38777
my $cities = qr/San Fransisco|Los Angeles/i;
Perl regular expression modifiers
Upvotes: 10