|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-11-24 17:53 UTC] johannes@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 20:00:01 2025 UTC |
Description: ------------ A Regex command normally replaces (using preg_replace), but only when there is just one string to match in line. Otherwise it gives some unexpected(weird) code. I've tried some *similar* codes, and they are all buggy in the same way. Reproduce code: --------------- $s = preg_replace("#\[url\=(.*)\](.*)\[\/url\]#i", "<a href=\"$1\" target=\"_blank\">$2</a>", $s); Then, for instance, a $s would be: EXAMPLE #1 If you dunno, or have no idea, you can try looking up [url=http://www.here.com]here[/url]. EXAMPLE #2 If you dunno, or have no idea, you can try looking up [url=http://www.here.com]here[/url] or [url=http://www.anotherhere.com]here[/url] ! Expected result: ---------------- EXAMPLE #1 is fine, but I expect for EXAMPLE #2 to get this: If you dunno, or have no idea, you can try looking up <a href="http://www.here.com" target="_blank">here</a> or <a href="http://www.anotherhere.com">here</a> ! Actual result: -------------- EXAMPLE #1 works fine, I get this: If you dunno, or have no idea, you can try looking up <a href="http://www.here.com" target="_blank">here</a>. EXAMPLE #2 doesn't work fine, I get this: If you dunno, or have no idea, you can try looking up <a href="http://www.here.com]here[/url] or [url=http://www.anotherhere.com" target="_blank">here</a> !