Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^5: Suggestion for regular expression speed improvement.

by demerphq (Chancellor)
on Jun 15, 2009 at 14:25 UTC ( #771666=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Suggestion for regular expression speed improvement.
in thread Suggestion for regular expression speed improvement.

You need to think out of the box. Make your system handle the various cases. A regex, a split, an unpack, maybe even an xml parser....

Definitely doing it the way you are is wrong. If you are really insistent on ignoring our advice (unwise really), then at least use inversion and you might want to investigate the (?>...) construct "atomic matching". As well as adding anchors to your pattern.

---
$world=~s/war/peace/g


Comment on Re^5: Suggestion for regular expression speed improvement.
Re^6: Suggestion for regular expression speed improvement.
by moritz (Cardinal) on Jun 15, 2009 at 14:34 UTC
    Make your system handle the various cases. A regex, a split, an unpack, maybe even an xml parser....

    I agree. The simplest solution is to make the caller supply a code reference, which you then call and which does the parsing/matching/unpacking/whatever.

Re^6: Suggestion for regular expression speed improvement.
by bala.linux (Novice) on Jun 15, 2009 at 14:46 UTC
    Exactly. This was my approach but before taking that up I wanted to check with the community whether Im doing anything wrong with regular expression. May be I expected too much from the regular expression. Anyway, thanks for your inputs :)

      Well no, its just that if you use a big huge complex machine to do the work that you could do with a knife that you arent being efficient.

      And split does use the regex engine, its just it uses it in special ways to be efficient.

      ---
      $world=~s/war/peace/g

        Yes. My initial idea was to keep CSV, RE parsing separate but I thought may be If could get the same performance from RE, then need not to have a CSV parser. But now I understand that is not possible to think of. So, need to switch back to my old approach where I do two parsing separately. So, from the user interface user will have simple/advanced parsing modes. Thanks for your suggestion.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (12)
As of 2014-07-14 08:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (257 votes), past polls