I have a pregexpression and its not outputting anything. Can someone explain why this might be? I'm also new to learning this

preg_match_all("/\<b>\$(.*?)\<\/b\>/is", $res[0], $match);
foreach($match[0] as $value) 
	echo "<div class='prices' id='kgbdealsPrice'>".$value."</div>";

The string that I'm trying to get looks something like this

<b>$ content </b>

I even used regex coach to see if it'll get that

<b>$ content </b>

and it does get it. but its just not outputting it on my page?

Any suggestions?


by the way, those div and td tags are just examples, the real one is a little more complex, but that shouldnt matter right? as long as there's only the <b>$ ... </b> text.

Hey, I am no expert in regexp but quite recently I had the same problem with escaping a $ sign. Just like you I used a single backslash to escape it and when it did not work I experimented with double backslashes and it did work then. I do not know exactly why. I did try to find out why but I'm afraid I was unable to get a satisfactory answer. I did however got introduced to preg_quote function that adds a backslash to every special character. There seems to be some issues in the function but for me it has worked without an issue. Even the $ sign issue after being passed through the function seems to be working. I hope this answer is of some help to you. :Dhttp://my2.php.net/preg_quote

hmmm very interesting. it works now.

I also tried a different code grabbing everything in the div where the $ is contained, and i still had a problem there. so we can't be able to get any $ text from preg_match?


thank you