[英]Shortcut for matching accented characters
In regex, there are shortcuts, like \\w
or az
. 在正则表达式中,有快捷方式,如
\\w
或az
。
In the same way, is there an alternative to writing all wanted accented symbols (for instance, transforming [éèàêâûôîùÈ...]
into \\ê
)? 以同样的方式,是否有替代编写所有想要的重音符号(例如,将
[éèàêâûôîùÈ...]
转换为\\ê
)?
For example: 例如:
$t = "Normal text éèàêâûôîùÈ more text";
preg_match_all('/[^\P{Latin}\x00-\x80]+/u', $t, $m);
print_r($m);
Result: 结果:
Array
(
[0] => Array
(
[0] => éèàêâûôîùÈ
)
)
Basically, this selects all "latin" characters (=letters), except those in the lower ascii range (=a..z). 基本上,这会选择所有“拉丁”字符(=字母),但下ascii范围(= a..z)除外。 Not sure if this can be called a "shortcut" though ;)
不知道这是否可以被称为“捷径”;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.