Is there a way to make Perl regex searches case-insensitive?

后端 未结 2 1199
时光说笑
时光说笑 2021-01-20 05:22

Example:

my $cities = qr/San Francisco|Los Angeles/;

The scalar $cities will match San Francisco and Los An

相关标签:
2条回答
  • 2021-01-20 05:35
    my $cities = qr/San Fransisco|Los Angeles/i;
    

    Perl regular expression modifiers

    0 讨论(0)
  • 2021-01-20 05:53

    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.

    0 讨论(0)
提交回复
热议问题