regexp help please!
| From: | Justin French | Date: | Mon, 22 Sep 2003 01:20:59 +0000 |
| Subject: | regexp help please! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-163389@lists.php.net to get a copy of this message | ||
I'm writing a PHP script inspired by smartypants and textile (but for PHP), which among other things does smart quoting.
However, I want to avoid smart quotes inside all tags (all quotes inside < and >). Since there are numerous functions accounting for numerous special cases, AND the fact that there will be very few tags with quotes (<a> is all so far), I'm thinking it's be easiest to go back through the converted text and replace all converted smart characters back to stupid ones
something like
$out = preg_replace("/<(.*?)[“|”](.*?)>/","<\\1\"\\2>",$in); // doubles
$out = preg_replace("/<(.*?)[’|̵](.*?)>/","<\\1'\\2>",$in); // singles
would be nice, but it isn't working, and I think this is stretching my skills in preg's waaay too far.
simularly, I'd like to preserver / de-convert any text contained with <pre></pre> tags
Any hints would be great!
Justin French