Regular expression - PCRE (PHP) - word boundary (\b) and accent characters

前端 未结 2 496
挽巷
挽巷 2021-01-21 16:22

Why does the letter é count as a word boundary matching \\b in the following example?

Pattern: /\\b(cum)\\b/i

Text:

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-21 17:15

    To deal with unicode, replace \b with

    /(?<=^|\PL)(cum)(?=\PL|$)/i
    

提交回复
热议问题