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 Link to comment https://forums.phpfreaks.com/topic/178144-reg-ex/ 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 Link to comment https://forums.phpfreaks.com/topic/178144-reg-ex/#findComment-939374 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 ???) } Link to comment https://forums.phpfreaks.com/topic/178144-reg-ex/#findComment-939380 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.'; } ?> Link to comment https://forums.phpfreaks.com/topic/178144-reg-ex/#findComment-939387 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? Link to comment https://forums.phpfreaks.com/topic/178144-reg-ex/#findComment-939599 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.