Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Analyzing regular expression performance

by Sprad (Hermit)
on May 12, 2006 at 16:54 UTC ( [id://549063]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Analyzing regular expression performance
in thread Analyzing regular expression performance

Changing the $sp regex to (?:\s*) cut runtime to almost nothing, so it looks like that's where my problem is.

I do need to allow comments anywhere in the string, though -- including having comments right after comments. Is there a cleaner way of doing that?

---
A fair fight is a sign of poor planning.

Replies are listed 'Best First'.
Re^4: Analyzing regular expression performance
by grinder (Bishop) on May 12, 2006 at 19:04 UTC

    I do think you are insane to parse SQL with regular expressions, but if you are brave and insist on this approach, I would suggest a multi-pass approach.

    Write one pattern that strips out comments. Write another pattern to coalesce blanks into a single blank. Then you will find that writing a third pattern to pick apart an expression becomes much easier. At least you won't need so many nested 0-or-many groupings -- that is what is killing your performance.

    I tried to run your code and it ate up all available memory... I do no think this approach will scale.

    • another intruder with the mooring in the heart of the Perl

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://549063]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2025-05-23 01:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.