I need to validate a text input so a user can insert characters/text that may include German umlauts, French accents and any other valid European characters, for example the minuscule ø.
I am using AngularJS so I am applying my validation rule to the ng-pattern
attribute like so:
ng-pattern="/^[A-Za-z0-9 \-_.]*$/"
I was hoping this would cover characters like äöüß but when testing it doesn't. Sorry to ask such a lame question but I am really bad at RegEx! There must be a better way than manually listing the letters like so ng-pattern="/^[A-Za-z0-9äöüÄÖÜ \-_.]*$/"
The Umlaut is the pair of dots placed over certain vowels; in standard German and its dialects, these vowels are ä, ö, ü.
Using JavaScript, the full name validation can be easily implemented in the form to check whether the user provides their first name and last name properly. The REGEX (Regular Expression) is the easiest way to validate the Full Name (first name + last name) format in JavaScript.
String regularExpression= "^[A-Za-z][A-Za-z0-9_]{7,29}$"; A valid username should start with an alphabet so, [A-Za-z]. All other characters can be alphabets, numbers or an underscore so, [A-Za-z0-9_]. Since length constraint was given as 8-30 and we had already fixed the first character, so we give {7,29}.
Javascript regexes don't support unicode properties, the only way to include non-latin letters is to list them explicitly in your expression:
[A-Za-z0-9 \-_.äöüß etc]
or use unicode ranges, e.g
[A-Za-z0-9 \-_.\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]
(see http://www.utf8-chartable.de/ for reference).
[a-zA-Z\x7f-\xff]
contains a lot of special characters such as ä ö ü é ß î...
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