Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: differnce between egrep and perl regex ?

by maard (Pilgrim)
on Oct 16, 2004 at 08:21 UTC ( [id://399741]=note: print w/replies, xml ) Need Help??


in reply to differnce between egrep and perl regex ?

So I think I need another little gem to find all alternations and sort them by size of literal so the longest possible match is returned. sounds like a task full of pitfalls. Any ideas how I can efficiently shell out 700 egreps a few times a second ? I thought perhaps I could generate a shell script with perl conatining all the egreps and returning the line number of the one it matched then just fork once to this shell but of course the shell still forks a child for each egrep, no win there :-(

If you want speed then forking for each of 700 egreps isn't good, of course. Depending on complexity of your rexegps you can or cannot just use some DFA to NFA conversion tool. So probably manual conversion of all regexes worth it, especially if new regexps are added too seldom, as I understood from your post.
As for longest match, just reorder alternations from longest to shortest. Also, in MRE there's an example of finding rightmost longest match, maybe you will find that useful.

  • Comment on Re: differnce between egrep and perl regex ?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-20 01:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found