This is a discussion on Re: [PHP] preg_match_all within the PHP General forums, part of the PHP Programming Forums category; * Thus wrote Floris (florisvankempen@home.nl): > hi, > I have this piece of code. but the problem is that ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
* 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." |