|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-06-22 17:52 UTC] tony2001@php.net
[2005-06-22 18:01 UTC] php at karsites dot net
[2005-06-22 18:04 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 19:00:01 2025 UTC |
Description: ------------ I'm actually on php4-4.3.8-8.7 - stuck with that at the moment,as that ships with my Linux distro - SuSE 9.2 pro I did search the database for 'coments' but found nothing there regarding this possible bug. The code below trashes the script with the commented line in the script // original regex $regex = "!(</?)(\w+)([^>]*?>)!e"; Surely, everything to the right of // should be ignored as a comment? With the comment in place, the script produces the following trashed output: )!e"; $regex = "!(]*?>)!e"; $replacement = "'\\1'.strtolower('\\2').'\\3'"; $subject = " A rose"; echo "Before replacement \$subject is: $subject "; $new_sub = preg_replace($regex, $replacement, $subject); echo "After replacement \$subject is: $new_sub "; ?> Is this a bug, because it is not expected behaviour. If I remove the offending comment, the script produces the correct output. Regards - Keith Roberts Reproduce code: --------------- <?php // original regex $regex = "!(</?)(\w+)([^>]*?>)!e"; $regex = "!(</?)(\w+)([^>]*?>)!e"; $replacement = "'\\1'.strtolower('\\2').'\\3'"; $subject = "<BIGTEXT> A <BIGGEST>rose</BIGGEST> <PARA></BIGTEXT>"; echo "Before replacement \$subject is: $subject <br />"; $new_sub = preg_replace($regex, $replacement, $subject); echo "After replacement \$subject is: $new_sub <br />"; ?> Expected result: ---------------- Before replacement $subject is: A rose After replacement $subject is: A rose (the browser ignores the dummy tags, but the correct result can be seen with 'view source code' - ie lowercased tags) Actual result: -------------- )!e"; $regex = "!(]*?>)!e"; $replacement = "'\\1'.strtolower('\\2').'\\3'"; $subject = " A rose"; echo "Before replacement \$subject is: $subject "; $new_sub = preg_replace($regex, $replacement, $subject); echo "After replacement \$subject is: $new_sub "; ?>