I am using JS Animated Contact Form with this line of validation regex:
rx:{".name":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'}, other fields...
I just found out, that I can't enter name like "Müller". The regex will not accept this. What do I have to do, to allow also Umlauts?
To match a character having special meaning in regex, you need to use a escape sequence prefix with a backslash ( \ ). E.g., \. matches "." ; regex \+ matches "+" ; and regex \( matches "(" . You also need to use regex \\ to match "\" (back-slash).
[a-zA-Z]* matches zero or more upper- or lower-case letters in a row. ^[a-zA-Z]+$ matches a string that STARTS with one-or more upper- or lower-case letters and also ends with it. Meaning, the only thing in your string is upper- or lower-case letters.
The backslash in combination with a literal character can create a regex token with a special meaning. E.g. \d is a shorthand that matches a single digit from 0 to 9. Escaping a single metacharacter with a backslash works in all regular expression flavors.
++ From What is double plus in regular expressions? That's a Possessive Quantifier. It basically means that if the regex engine fails matching later, it will not go back and try to undo the matches it made here.
You should use in your regex unicode codes for characters, like \u0080
. For German language, I found following table:
Zeichen Unicode ------------------------------ Ä, ä \u00c4, \u00e4 Ö, ö \u00d6, \u00f6 Ü, ü \u00dc, \u00fc ß \u00df
(source http://javawiki.sowas.com/doku.php?id=java:unicode)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With