Search code examples
phpregexpreg-match

preg match everything except a letter


Is there a shorthand for the opposite of this? \p{L}

I want to match everything except a letter.. a-zA-ZæøåÆØÅ ...

You could of course do this [^\p{L}] but is there a shorter way of doing it?


Solution

  • You can use property \P{L} to may any unicode non-letter.

    • \P{L} matches any characters that \pL does not

    RegEx Demo