preg_match_all php variable

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
iWuha
Forum Newbie
Posts: 2
Joined: Tue May 09, 2006 9:32 pm

preg_match_all php variable

Post by iWuha »

Hi,

I'm trying to search for a particular word in a string by doing :

Code: Select all

preg_match_all("/\b" . $result2['terms'] .  "\b/i", $cont, $words);
However, I'm getting this warning:

Code: Select all

warning: preg_match_all(): Unknown modifier 'r' in C:\Program Files\Software\Developer\Database\xampp\htdocs\db\includes\common.inc(1150) : eval()'d code on line 54.
Submitted by ausfood on Mon, 05/08/2006 - 22:52.
Keyword : ground are found 1 times
Keyword : clear are found 1 times
Keyword : Sarlija are found 5 times
Why is that happening? Any help on this would be appreciated. Thanks! :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$result2['terms'] has slashes inside it would appear.
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post by sweatje »

Try

Code: Select all

preg_match_all("/\b" . preg_quote($result2['terms'],'/') .  "\b/i", $cont, $words);
Post Reply