Coreye Posted February 24, 2008 Share Posted February 24, 2008 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 More sharing options...
ucffool Posted February 24, 2008 Share Posted February 24, 2008 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 More sharing options...
Coreye Posted February 24, 2008 Author Share Posted February 24, 2008 It's the INPUT we are trying to do. Thanks for the suggestion, but that didn't work. Link to comment https://forums.phpfreaks.com/topic/92756-regex-help/#findComment-475276 Share on other sites More sharing options...
Coreye Posted February 25, 2008 Author Share Posted February 25, 2008 Thanks, I got it working now . Link to comment https://forums.phpfreaks.com/topic/92756-regex-help/#findComment-475467 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.