Finding a way to preg_match all special letters

Viewed 32

Basically I was trying to preg_match all Letters and special letters for example: ä,â,ã… But I‘ve come across to a problem. Preg_Matching only letters was pretty easy since you only need the following code: preg_match("/^[a-zA-Z]+$/") the hard part was when adding all special letters. I‘ve come across some methods like preg_match("/^[äöü ÄÖÜ a-z-]+$/") to manually preg_match some special letters but isn’t there something like a syntax that can preg_match all of the special letter?

1 Answers

I think I’ve found an answer for my question with the following code:

preg_match('/[^\pL\s-]/u', $string)

This should work since it should accept all special letters but I‘ve not tested it.

Related