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

后端 未结 2 1198
时光说笑
时光说笑 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: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.

提交回复
热议问题