Re: Problems with patterns
| From: | Jason Barnett | Date: | Thu, 22 Apr 2004 00:45:29 +0000 |
| Subject: | Re: Problems with patterns | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-184169@lists.php.net to get a copy of this message | ||
What kinds of phrases are you looking for? If you want to know whether an *exact* phrase is going to appear in a block of text, just use strstr() or strpos(), they tend to be faster than regexes anyway.
http://www.php.net/strpos
function valid_phrase ($phrase, $search = 'text to search for') {
return strpos($phrase, $search);} If you really want to use ereg though, you'll need to search for whitespace characters (or maybe just spaces, depending on your need). But I think strpos() will be fine for what you want to do.