有没有办法让 Perl 正则表达式搜索不区分大小写? [英] Is there a way to make Perl regex searches case-insensitive?

查看:128
本文介绍了有没有办法让 Perl 正则表达式搜索不区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:

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

标量 $cities 将匹配 San FranciscoLos 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 正则表达式修饰符

这篇关于有没有办法让 Perl 正则表达式搜索不区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆