Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex for Umlaut

Tags:

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?

like image 814
user1555112 Avatar asked Feb 25 '14 14:02

user1555112


People also ask

How do you denote special characters in regex?

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).

What is a zA z ]+?

[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.

What is Slash's regex?

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.

What does ++ mean in regex?

++ 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.


1 Answers

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)

like image 98
IProblemFactory Avatar answered Oct 02 '22 00:10

IProblemFactory