View Full Version : Regex Help

02-24-2008, 09:05 PM
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:

$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

$message = "/color 'Corey' '000'";

I assumed this regex would work but it doesn't.

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.


02-24-2008, 10:43 PM
if (ereg ("^/(ban|color|invisible) [\"\'](.*)[\"\'] [\"\'](.*)[\"\']", $message, $cmd))

best rgards

02-25-2008, 01:36 AM
Thanks :).

I got it working using:

if (eregi("^/(ban|color|invisible) '([a-z0-9_ ]+)' (.*)", $cmd, $regs))