Username: Posted January 8, 2011 Share Posted January 8, 2011 I want to make it so if($message=="" . $cmdPrefx . "deleteall: "){ echo substr(strrchr($message, ' '), 1); Doesn't use =="something" How can I make it so anything after deleteall: is a wildcard? I'm assuming using regex, but have no idea how Quote Link to comment https://forums.phpfreaks.com/topic/223761-help-with-str-or-regex/ Share on other sites More sharing options...
RichardRotterdam Posted January 8, 2011 Share Posted January 8, 2011 your if statement is incorrect either do: if($message == $cmdPrefx . "deleteall: "){ echo substr(strrchr($message, ' '), 1); } or: if($message == $cmdPrefx . "deleteall: ") echo substr(strrchr($message, ' '), 1); How does this have to do with a wildcard or regex? Edit After reading it again I think i missread. Do you mean you want it to do a comparison on what the message starts with? What exactly do you want the if statement to do? Quote Link to comment https://forums.phpfreaks.com/topic/223761-help-with-str-or-regex/#findComment-1156619 Share on other sites More sharing options...
Username: Posted January 8, 2011 Author Share Posted January 8, 2011 Sorry for not being more clear I want any text AFTER "deleteall: " to be selected. So if $something = ">deleteall: Username:" It will ignore ">deleteall: " and only select "Username:" Quote Link to comment https://forums.phpfreaks.com/topic/223761-help-with-str-or-regex/#findComment-1156620 Share on other sites More sharing options...
noXstyle Posted January 8, 2011 Share Posted January 8, 2011 Theres couple of ways to achieve that... either use str_replace, str_pos & substr or regex... with str_replace it would look something like: $something = ">deleteall: Username:"; $s = $cmdPrefx."deleteall: "; $yourstring=str_replace($s, "", $something); Quote Link to comment https://forums.phpfreaks.com/topic/223761-help-with-str-or-regex/#findComment-1156632 Share on other sites More sharing options...
sasa Posted January 8, 2011 Share Posted January 8, 2011 try <?php $message = '>deleteall: blah sasa'; $cmdPrefx = '>'; if(stripos($message, $cmdPrefx.'deleteall: ') === 0) echo substr(strchr($message, ' '), 1); ?> Quote Link to comment https://forums.phpfreaks.com/topic/223761-help-with-str-or-regex/#findComment-1156749 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.