Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Reverse engineering regular expressions

by Joost (Canon)
on Aug 01, 2005 at 01:15 UTC ( #479769=note: print w/replies, xml ) Need Help??


in reply to Reverse engineering regular expressions

Interesting problem, but I wonder why you would want to solve it.

If you "just" want something to help you explain a regex, Regex Coach is helpful.

If you want to support the perl code-extensions - (?{ ... }) and friends - you can't. Update: after some more reading, lookaheads are tricky too, you're probably restricted to "classical" regular expressions + a few extensions.

Generating a "minimal" string that would match a regex (i.e. drop everything with a * modifier, drop everything after a |, take the first character of a characterset etc) should not be too hard (famous last words...) as long as you get the parser right. I suggest you take an existing one like YAPE::Regex or Regexp::Parser.

Oh, and while I was looking for those modules on cpan, I also found Regexp::Genex - it seems to do what you want. :-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2021-02-28 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?