SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Setting up a connection... mgyth's Avatar
    Join Date
    Nov 2004
    Location
    Mosjen - Norway
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ereg and other languages...

    Hi.
    I'm trying to validate a form using ereg().
    But it's a Norwegian page and the characters: , and , will appear. Thus making the form validation false.
    How can I, if possible, adapt ereg to recognise these characters as valid?

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    rebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    You can specify any characters you want as shown below.

    PHP Code:
    if(ereg('^[a-zA-Z]+$'$string)) 
    I hope this can help you.

    Yours, Erik.

  3. #3
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The more common solution is to setup your locale accordingly (see http://www.php.net/manual/en/function.setlocale.php). Among regexps, this affects other vital things like sorting etc. And do not use ereg, it's deprecated.

  4. #4
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by stereofrog
    And do not use ereg, it's deprecated.
    Where is this announced?
    Lats...

  5. #5
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    rebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Quote Originally Posted by stereofrog
    And do not use ereg, it's deprecated.
    The ereg functions are not deprecated. However, it is better to use the PCRE functions since they are faster.

    Yours, Erik.


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
  •