Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Regex Help

  1. #1
    New Coder
    Join Date
    Nov 2007
    Location
    St.Louis MO
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Regex Help

    Hey guys, I didn't see a regex board, so if this is the wrong section, you can move it.

    I'm working on a script where you enter a command then a username then a 3rd arguement (in this case a hex code).

    This works:

    PHP Code:
    $message "/color Corey 000";
    if (
    ereg ("^/(ban|color|invisible) (.*) (.*)"$message$cmd)) 
    But I want the username and the 3rd argument to have quotes around them (single or double I really don't care at this point). Such as

    PHP Code:
    $message "/color 'Corey' '000'"
    I assumed this regex would work but it doesn't.

    PHP Code:
    if (ereg ("^/(ban|color|invisible) '(.*)' '(.*)'"$message$cmd)) 
    I've tried several other variations such as ['(.*)'] and other stuff too but I just can't get it to work.

    Thanks,
    Corey

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    PHP Code:
    if (ereg ("^/(ban|color|invisible) [\"\'](.*)[\"\'] [\"\'](.*)[\"\']"$message$cmd)) 
    best rgards

  • #3
    New Coder
    Join Date
    Nov 2007
    Location
    St.Louis MO
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks .

    I got it working using:
    PHP Code:
    if (eregi("^/(ban|color|invisible) '([a-z0-9_ ]+)' (.*)"$cmd$regs)) 
    Last edited by Corey; 02-25-2008 at 12:50 AM.


  •  

    Posting Permissions

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