unidox Posted October 18, 2009 Share Posted October 18, 2009 Im trying to search for the string: srv_9 (Dead ???) I thought to use preg_match, however I dont know much about reg ex. Can anyone help? Thankks Quote Link to comment Share on other sites More sharing options...
unidox Posted October 18, 2009 Author Share Posted October 18, 2009 What im trying to do is, search for "srv_9 (Dead ???)" inside a function output. Any ideas? Thanks Quote Link to comment Share on other sites More sharing options...
Garethp Posted October 18, 2009 Share Posted October 18, 2009 if(preg_match("~srv_9 \(Dead \?\?\?)~", $Var)) { //$Var contains srv_9 (Dead ???) } Quote Link to comment Share on other sites More sharing options...
thebadbad Posted October 18, 2009 Share Posted October 18, 2009 If you're searching for a plain string, use strpos() or stripos() for case insensitivity: <?php if (strpos($var, 'srv_9 (Dead ???)') !== false) { echo '$var contains the searched string.'; } ?> Quote Link to comment Share on other sites More sharing options...
cags Posted October 19, 2009 Share Posted October 19, 2009 I rather suspect that the ??? aren't question marks but are characters the OP wants returning... I guess the OP will confirm this if thats what they are interested in. If it is then we will need to know what characters are valid how many of them there should be etc. etc. Also why post a topic in the 'PHP Coding Help' section called 'Reg Ex' when theres a forum specifically for Regular Expressions? Quote Link to comment 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.