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? 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. 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 ?> 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? 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. 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"";} ?> 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. Link to comment https://forums.phpfreaks.com/topic/71038-help-with-regex/#findComment-357221 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.