本文介绍了有没有办法让 Perl 正则表达式搜索不区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
示例:
my $cities = qr/San Francisco|Los Angeles/;
标量 $cities
将匹配 San Francisco
和 Los Angeles
但不会匹配 SAN FRANCISCO
,洛杉矶
、san francisco
或 洛杉矶
.有没有办法让这些变量不区分大小写,而不必创建它们的大写版本?
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?
推荐答案
my $cities = qr/San Fransisco|Los Angeles/i;
这篇关于有没有办法让 Perl 正则表达式搜索不区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!