
G0ldfysh
New User
May 28, 2008, 8:59 AM
Post #1 of 2
(1178 views)
|
|
Regex character limitation confusion
|
Can't Post
|
|
I am new to using Perl and I am trying to use it to pre process html and javascript using the following regex stripping out sections of code not required. The unrequired sections are contained within comments to allow normal use without the perl pass through for during development. The regex I have are as follows and for all their possible clunkiness and no doubt they could be improved and speeded up some, they work to a point. Once the number of characters within the Leg-if and Leg-else comments exceeds a certain number it all fails and no match occurs. Is there a limit in expression matching? Or have I done something a little more fundemental than that ? The expressions $r = ($js =~ s/ \n\s* if[^\n]*? Leg-IF[^IF]*? Leg-ELSE / /sgx); $r = ($js =~ s/ \n\s* [\}\s]+ [^\n\w]*? Leg-ENDIF/ /gx); Any help would be appreciated, if more info is needed please let me know. //sample code to be passed through expression if (LegacyCode){ //Leg-IF functionOne(); functionTwo(); functionThree(); Four(); if this is our(); then works as desired } else { //Leg-ELSE bCheck=false; //keep me }//Leg-ENDIF Result should be to remove all the sample code just leaving the "bCheck=false; //keep me" line. Comments and white space stripping is working already. but a seperate pass through for clarity and options when debugging.
|