BRUm Posted August 27, 2006 Share Posted August 27, 2006 Hi,I'm currently coding a search engine, and everything seems to be going smoothly, until I reach regular expressions -_- (I hate them so much..). So far, the script can crawl a site from an array, and grab a sentence with the keywords. However, it's a bit messy, and I wondered if someone would be so kind as to show a pattern that would do it properly.Basically, I need a pattern that matches a sentence with letters and numbers only (to filter out HTML) and with the sentence must have this in: [code=php:0]$pieces[0][/code]Here's the code I'm using at the moment: [code=php:0]/$pieces[0].*/[/code] I must say it's not too good.Any help greatly appreciated,Thanks. Link to comment https://forums.phpfreaks.com/topic/18790-regex-pattern-for-sentence-with-word-in/ Share on other sites More sharing options...
effigy Posted August 28, 2006 Share Posted August 28, 2006 [code]if ( strstr($string, $pieces[0]) && preg_match('/^[A-Za-z0-9 .]$/', $string) ) { ... }[/code] Link to comment https://forums.phpfreaks.com/topic/18790-regex-pattern-for-sentence-with-word-in/#findComment-81600 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.