Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-24-2008, 08:05 PM   PM User | #1
Corey
New Coder

 
Join Date: Nov 2007
Location: St.Louis MO
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
Corey is an unknown quantity at this point
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
Corey is offline   Reply With Quote
Old 02-24-2008, 09:43 PM   PM User | #2
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
PHP Code:
if (ereg ("^/(ban|color|invisible) [\"\'](.*)[\"\'] [\"\'](.*)[\"\']"$message$cmd)) 
best rgards
oesxyl is offline   Reply With Quote
Old 02-25-2008, 12:36 AM   PM User | #3
Corey
New Coder

 
Join Date: Nov 2007
Location: St.Louis MO
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
Corey is an unknown quantity at this point
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..
Corey is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:12 PM.


Advertisement
Log in to turn off these ads.