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

Re: Regular Expression Builder

by erikharrison (Deacon)
on Aug 30, 2002 at 16:34 UTC ( [id://194163]=note: print w/replies, xml ) Need Help??


in reply to Regular Expression Builder

The challenge here is asking youself "What kind of regexes do I want my tool to generate". This makes things a little harder and is one of the reasons that this kind of tool isn't on the market.

A computer program cannot read your mind, obviously. So, the regexes generated from a single simple string will be rather simple - there isn't enough data to work with to create a complex expression there. For example, should the regex retain length? When should a regex generalize a character into a character class or match exactly? If we generalize out to a character class, what about when a character could be placed in several different character classes?

While the tool could produce more useful regexes from additional data (such as multiple strings) the question remains - by what rules do we generate a regex from the given data? The rules will vary from project to project, so a tool that has rules builtin will not be very useful to others, and as such won't be out there in the market. If you want a tool you can program regex generating rules into, you get into a layer of abstraction which makes things harder not easier on the programmer - you'd be better off generating the regexes yourself.

Some tools that might help you out - Parse::RecDecent Parse::Yapp and perhaps Regex::English.

Cheers,
Erik

Light a man a fire, he's warm for a day. Catch a man on fire, and he's warm for the rest of his life. - Terry Pratchet

Replies are listed 'Best First'.
OT: DWIM
by BorgCopyeditor (Friar) on Aug 30, 2002 at 19:11 UTC
    A computer program cannot read your mind, obviously.

    Darn. It sure would be helpful to be able to write:

    #!/usr/bin/perl use Read::Mind qw(disambiguate implement); $script = new Read::Mind; $script->do_what_I_mean(); exit;

    BCE
    --Dude, you're getting assimilated!

Re: Regular Expression Builder
by Brutha (Friar) on Sep 02, 2002 at 12:04 UTC
    What kind of regexes do I want my tool to generate

    E.g. give that generator a handfull Strings, recognize a possible pattern behind that and generate the regular expression to recognize these strings. That would cut the number of possible solutions down to a reasonable amount. Problem is the pattern recognition or is ther a module?

    And it came to pass that in time the Great God Om spake unto Brutha, the Chosen One: "Psst!"
    -- (Terry Pratchett, Small Gods)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-23 19:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found