如何在PHP中构建正则表达式,包含字母和重音/ circumflex / etc字符?

I have never worked with regular expressions. And now, at my job, I need a regular expression that accepts a string with:

(It is a full name that can have so many variants and many languages)

  • Blank spaces
  • Any quantity of numbers
  • Any quantity of alphabetic characters, including grave, acute, circumflex, tilde, diaresis, ring above, cedilla, etc. This is all variants of each letter. Example (A, À, Á, Â, Ã, Ä, Å)
  • Latin special characters (ñ Ñ, ç Ç)
  • German special character (ß)
  • En dash (-)

I am reading and studying documentation now, but I am stuck.

You could use something like this:

^[0-9\wÀ-ž\s\-]+$
  • 0-9 for numbers

  • \w for word characters

  • À-ž for the special characters

  • \s for spaces

  • \- for the -

wrapping this inside [] makes an class, which maches everything inside and putting a + after the class, says at least one element of this character class.