Why special characters like = or " break PHP regexp when using \b word boundary?

后端 未结 3 1598
臣服心动
臣服心动 2021-02-20 02:15

this is a follow up after reading How to specify "Space or end of string" and "space or start of string"?

From there, it states means to match a word

3条回答
  •  暖寄归人
    2021-02-20 02:48

    " is, of course, not special.

    The word boundary, \b, OTOH, is. It looks for a word beginning/ending, and on the boundary it expects a word character - and the quote is not such a character.

    Remove it from the end or replace it with a negative look-ahead search for a word character.

提交回复
热议问题