SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Regex] multilanguage

    Hi.
    What's wrong about this code:

    PHP Code:
    function isUser(val) { 
       return /^[[:
    alpha:]]+'?\s?[[:alpha:]]*$/.test(val); 

    I don't want digit characters

    I want to allow
    alphabetic characters
    (not only the english alphabet but also other country
    ie
    é,ò,ù,ì for italian
    ç for francais
    and so on )
    the single quote ( ' ) ie Dall'ulma
    the space ie De Andrè

    example
    Dell'Ogliè - good
    De Oçois - good
    Weißmüller - good
    Weißmüller3 - bad
    Bye.

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It's [:alpha:], with only one square bracket each side. Also, [:alpha:] isn't supported by JavaScript it seems, only the shorter \w and \w versions (see this). Also, [:alpha:] (and \w) only includes a-z and A-Z, not the extended European things.
    The way I see it, you have to include all the things you're not willing to accept, or vice-versa:
    Code:
    /^[^0-9.;:@"£$%\/^&\*()_+=]+$/
    or
    Code:
    /^[a-zA-ZçÇáÁéÉíÍ-]+'? ?[a-zA-ZçÇáÁéÉíÍ-]+$/
    Note that \s will also match a tab and newline character, so just use a normal space.

    Both routes have their pitfalls.

  3. #3
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks just a lot buddy
    I don't know that [:alpha:] isn't supported by JavaScript
    I'm using quite the same regex server side.

    Bye.

  4. #4
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I didn't know either, but after a few tests it seems JavaScript doesn't recognise [:alpha:], [unct:] and friends.

    Server side, does [:alpha:] include the other European characters (á, ë, ñ, etc.)?

  5. #5
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raffles View Post
    I didn't know either, but after a few tests it seems JavaScript doesn't recognise [:alpha:], [unct:] and friends.

    Server side, does [:alpha:] include the other European characters (á, ë, ñ, etc.)?
    Now I've made a better test NO

    Yeah, it's hard to work out.

    Do you have any idea yet ?

    By now I'm thinking I'm using your first way.


    Bye.


Bookmarks

Posting Permissions

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