正则表达式 - PCRE (PHP) - 字边界 (\b) 和重音字符 [英] Regular expression - PCRE (PHP) - word boundary (\b) and accent characters
本文介绍了正则表达式 - PCRE (PHP) - 字边界 (\b) 和重音字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么在下面的例子中字母 é
算作与 \b
匹配的词边界?
Why does the letter é
count as a word boundary matching \b
in the following example?
模式:/\b(cum)\b/i
文本:écumé
匹配不需要的cum".
Matches 'cum' which is not desired.
有没有可能克服这个问题?
Is it possible to overcome this?
推荐答案
当您将 u
修饰符添加到正则表达式时,它会起作用
It will work, when you add the u
modifier to your regex
/\b(cum)\b/iu
这篇关于正则表达式 - PCRE (PHP) - 字边界 (\b) 和重音字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文