more regex fun
| From: | kev | Date: | Fri, 02 Jun 2000 08:56:28 +0000 |
| Subject: | more regex fun | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-892@lists.php.net to get a copy of this message | ||
Hi,
I got this regex code working (thanks to Andreas and Zak) last night:
$urlvars = $nav->urlvars();
$ret = preg_replace( "/<B>(.*?)<\/B>/ei",
"\"<A
href=$searchpageurl?$urlvars&qu=\".urlencode('\\1').\"&hi=20&ty=any\".\"><B>\".'\\1'.\"</B></A>\"",
$text );
For description and example of wht it does, please see thread from last
night (started with "PHP function inside a regex - possible?" post).
Anyway, my problem now is that when there is an apostrophe or double
quote in \\1, I get a 'Failed evaluating code' error. I tried changing
qu=\".urlencode('\\1') to qu=\".urlencode(addslashes('\\1')), but this
made no difference.
Any ideas how I guard against single and double quotes?
thanks,
- Kev