CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Regex character limitation confusion

 



G0ldfysh
New User

May 28, 2008, 8:59 AM

Post #1 of 2 (2237 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.


KevinR
Veteran


May 29, 2008, 4:35 PM

Post #2 of 2 (2173 views)
Re: [G0ldfysh] Regex character limitation confusion [In reply to] Can't Post

Your requirements are too vague. Is "bCheck=false; //keep me" always the same? Is it always present? Is there some rule you can use to describe what you are trying to do?
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives