Jump to content

Regex Help


Coreye

Recommended Posts

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 Hood15 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 'Hood15' '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.

Link to comment
https://forums.phpfreaks.com/topic/92756-regex-help/
Share on other sites

Do you want the INPUT to have quotes or the OUTPUT?

If it is the output, that would be pretty straightforward and not part of the regex.

If it is the input, you could make it something like:

eregi ("^/(ban|color|invisible) ('[a-z0-9_-]') ('[a-z0-9]')", $message, $cmd

Using eregi so it ignores case.

Link to comment
https://forums.phpfreaks.com/topic/92756-regex-help/#findComment-475254
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.