I need to strip legacy ASP code from include files in a PHP app – I’m attempting to match everything between <% and %> with the regexp /(<%([.\r\n\r])+%>)/ through preg_replace, but it’s failing. Where did I go wrong?
I need to strip legacy ASP code from include files in a PHP app
Share
The dot
[.]does not apply to all characters when inside a [character class]. Consider this one instead:It can be read as “match <% then as few of anything as possible, followed by %>”. This lazy one won’t eat the code inbetween <% … %> and the next <% … %>.