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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.