Results 1 to 7 of 7

Thread: Regular expression for Alt Gr

  1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    208
    Answers
    2
    Vote Rating
    0
      0  

    Default Answered: Regular expression for Alt Gr

    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 ?

  2. Code:
    /[a-zA-Z\s\u00E1\u00E9\u00ED\u00F3\u00FA]/

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,790
    Answers
    583
    Vote Rating
    391
      0  

    Default

    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.

  4. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    208
    Answers
    2
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by skirtle View Post
    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]/

  5. #4
    Sencha User
    Join Date
    Mar 2011
    Posts
    208
    Answers
    2
    Vote Rating
    0
      0  

    Default

    I tried above which I showed last post but didnt work.
    how to use \uXXXX

  6. #5
    Sencha User
    Join Date
    Mar 2011
    Posts
    208
    Answers
    2
    Vote Rating
    0
      0  

    Default

    I used this way /([a-zA-Z\s]+)$\uXXXX/,

    but didnt work..!!

  7. #6
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,790
    Answers
    583
    Vote Rating
    391
      0  

    Default

    Code:
    /[a-zA-Z\s\u00E1\u00E9\u00ED\u00F3\u00FA]/

  8. #7
    Sencha User
    Join Date
    Mar 2011
    Posts
    208
    Answers
    2
    Vote Rating
    0
      0  

    Default

    Thx Kirtle it works fine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •