正则表达式和重音符号 [英] Regex and accents/tildes
本文介绍了正则表达式和重音符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该如何在正则表达式中包含重音符号?我想检测 az
和äáàëéèííööóòúùñç
的字母,但是此正则表达式不起作用:
How should I include accents into a regex? I'd like to detect letters from a-z
and äáàëéèíìöóòúùñç
but this regex doesn't work:
$pattern = '/^([a-zäáàëéèíìöóòúùñç])/i';
推荐答案
在这里您可以找到我的问题的解决方案:
使用正则表达式和preg_replace_callback
,似乎正则表达式必须像这样:$ pattern ='/(\p {L})(。+)/ iu';
Here you can find the solution to my problem: Using of regex whith preg_replace_callback , it seemed the regex has to be like: $pattern = '/(\p{L})(.+)/iu';
这篇关于正则表达式和重音符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文