Regular Expression - using the ?:
| From: | WILSON, Nick | Date: | Sun, 03 Sep 2000 22:28:19 +0000 |
| Subject: | Regular Expression - using the ?: | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-15019@lists.php.net to get a copy of this message | ||
Okay so it's not quite the bees knees of reg exp, but I want to
replace the text ' action="./somedir/somepage.xxx">' where the
double quotes may or may not be there, as might the > as the end.
But I don't want the > at the end matched.
$replace = ' action="http://www.myserver.com.au/mypage.php3"
';
$text = preg_replace('|\s+action\s*=\s*.*?(?:[>\s])+|i', "$replace" ,
$in_text));
echo "$text";
It seems to match for most things, except when $in_text is
action=/page.asp>
It still matches the >, but shouldn't the ?: not include the
matched > in the text to replace ?
Can someone else try this in a script or tell me if it's a 'special'
feature of php.
Thanks,
Nick