subnet_rx Posted September 28, 2007 Share Posted September 28, 2007 I've never been that good with regex. I have a variable that contains a string (an HTML file). I'm looking for the phrase: "Unable to open RSS Feed". How would I look for this in this variable? Quote Link to comment https://forums.phpfreaks.com/topic/71038-help-with-regex/ Share on other sites More sharing options...
effigy Posted September 28, 2007 Share Posted September 28, 2007 For something that simple, use strpos. Quote Link to comment https://forums.phpfreaks.com/topic/71038-help-with-regex/#findComment-357172 Share on other sites More sharing options...
darkfreaks Posted September 28, 2007 Share Posted September 28, 2007 <?php strpos($string,"Unable to open RSS Feed");///will return first occurence of unable to find rss feed ?> Quote Link to comment https://forums.phpfreaks.com/topic/71038-help-with-regex/#findComment-357178 Share on other sites More sharing options...
subnet_rx Posted September 28, 2007 Author Share Posted September 28, 2007 If it's not found, will it just return false or an error? Quote Link to comment https://forums.phpfreaks.com/topic/71038-help-with-regex/#findComment-357193 Share on other sites More sharing options...
effigy Posted September 28, 2007 Share Posted September 28, 2007 Follow the link. It has documentation: For something that simple, use strpos. Quote Link to comment https://forums.phpfreaks.com/topic/71038-help-with-regex/#findComment-357195 Share on other sites More sharing options...
darkfreaks Posted September 28, 2007 Share Posted September 28, 2007 i dont think it would do anything if not found but you could do <?php if $string=!strpos($string,"Unable to open RSS Feed") { echo "Error: could not find "Unable to open RSS Feed"";} ?> Quote Link to comment https://forums.phpfreaks.com/topic/71038-help-with-regex/#findComment-357202 Share on other sites More sharing options...
subnet_rx Posted September 28, 2007 Author Share Posted September 28, 2007 Thanks, yeah, it said to test with === which I've never personally used before, but I'm about to give this a try. Due to circumstances out of my control, it's going to go on a production server without testing on the particular platform so that's why I'm trying to get my ducks in a row. Quote Link to comment https://forums.phpfreaks.com/topic/71038-help-with-regex/#findComment-357221 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.