SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    what wrong about regular expression


    I write regular expression like this
    ^[a-zA-Z0-9 _]+$

    my purpose
    match lower case character
    match upper case character
    match number 0 - 9
    match underscore and blank
    these character must at leash 1 character or more

    Is i write correct? because when i test with word "hello every" it doesn't match and when i test with another word such as
    "database system" it match

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about you post the code you're using?

  3. #3
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a textbox name=Name_Eng
    when i enter hello every on textbox
    and enter submit button it write Incorrect input

    if (!ereg("^[a-zA-Z0-9 _]+$",$Name_Eng))
    {
    $Error=1;
    print "Incorrect input<BR>";
    }

  4. #4
    SitePoint Zealot DarkMonkey's Avatar
    Join Date
    Apr 2001
    Location
    uk
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    are you sure you havn't misspelled your textbox name or something? Easy to do and then the variable would be empty and thus be false with you regexp.

    You could also try e"^([a-zA-Z0-9 _])+$", $Name_Eng

    also, the space in 'hello everybody' or whatever might be mucking with it.

    e"^([a-zA-Z0-9\w _])+$", $Name_Eng

    Might fix it. Dunno if you can do \w in character classes, I'm a bit rusty.


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
  •