php - regular expression for commenting out all print statements in a file if followed by a particular string -
i have file looks similar this:
<?php print "hello world" . "<br/>"; print "foobar" . "<br/>"; ... // process parameter if ($var) { print $var . "<br/>"; } ... print "foo" . "<br/>"; ... print "bar" . "<br/>"; ... >?
i need regular expression comments out print statements, if said statements appear after process parameter
comment.
i'm using perl process file above, way.
i've come following regex it's not working:
~(?s)(// process parameter.*?)print(.*?\?\>)~$1//print$3~gi
do need use regex conditional? appreciate help.
thank you.
thank suggestions. did figure out, though.
~(?s)(?<=// process parameter.*?)(print.*?)~//$1~gi
i'm using look-behind assertion s option treat string single line. matches print if followed contents of look-behind assertion.
Comments
Post a Comment