Re: preg_match_all
| From: | Curt Zirzow | Date: | Tue, 23 Sep 2003 18:16:28 +0000 |
| Subject: | Re: preg_match_all | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-163613@lists.php.net to get a copy of this message | ||
* Thus wrote Floris (florisvankempen@home.nl):
> hi,
> I have this piece of code. but the problem is that he also links parts of
> words (like: credits) and i wnat only standalone words (like: edit)
> Does someone have i idea to correct this piece of code?
>
> Floris
>
> {
> $regex1 = ">[^<]*(";
> $regex2 = ")[^<]*<";
> preg_match_all("/".$regex1.$search_word.$regex2."/i", $string, $matches,
Use the word boundry character:
$regex1 = ">[^<]*\b(";
$regex2 = ")\b[^<]*<";
Curt
--
"I used to think I was indecisive, but now I'm not so sure."