Why preg_match(“/[^(22|75)]/”, “25”) returns false?

前端 未结 5 1729
误落风尘
误落风尘 2021-01-29 08:31

I want to test that a given string does not belong to the following group of strings: 22 75.

Could anyone please tell why PHP\'s preg_match(\"/[^(22|75)]/\

5条回答
  •  情书的邮戳
    2021-01-29 08:56

    In regular expression, [...] match any character inside the bracket.

    To be more correct:

    • [^...]: match any charcter not listed inside the bracket. (^: negate)

    Remove the [, and ] if you want to match string that starts with 22 or 76.

提交回复
热议问题