PDA

View Full Version : Regular expression for Alt Gr



bee
28 Oct 2011, 2:14 AM
Hi I want to add characters in my textfield along with albhabets and spaces
maskRe : /([a-zA-Z\s]+)$/, for my textfield please let me know which regex to be used for these spacila characters as well ?

skirtle
28 Oct 2011, 6:46 AM
maskRe is run against a single character, as it is typed. Your existing regex is quite a bit more complicated than it needs to be, the (), + and $ are all unnecessary.

For the accented characters, have you tried just adding those characters to your character class (the thing surrounded with square brackets)? If that doesn't work, try escaping them in the form \uXXXX to avoid any character encoding problems.

bee
28 Oct 2011, 7:20 AM
maskRe is run against a single character, as it is typed. Your existing regex is quite a bit more complicated than it needs to be, the (), + and $ are all unnecessary.

For the accented characters, have you tried just adding those characters to your character class (the thing surrounded with square brackets)? If that doesn't work, try escaping them in the form \uXXXX to avoid any character encoding problems.
You meant to say should I mention this way ?
/[a-zA-Z\s]/

bee
28 Oct 2011, 7:26 AM
I tried above which I showed last post but didnt work.
how to use \uXXXX

bee
28 Oct 2011, 7:28 AM
I used this way /([a-zA-Z\s]+)$\uXXXX/,

but didnt work..!!

skirtle
28 Oct 2011, 7:37 AM
/[a-zA-Z\s\u00E1\u00E9\u00ED\u00F3\u00FA]/

bee
28 Oct 2011, 8:22 PM
Thx Kirtle :) it works fine