Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Regular Expression Builder

by erikharrison (Deacon)
on Aug 30, 2002 at 16:34 UTC ( #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.


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'.
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;

    --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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://194163]
[choroba]: I'm curious which part of your signature do they find offensive.
[LanX]: they?
[LanX]: click!
[choroba]: they
[LanX]: why do you think it's more than one person?
[Your Mother]: Because we are LEGION! Fix YOUR SIG SIG BLOCK!!!!
[Your Mother]: Forgot to sign in as my sockpuppet, how embarrassing!
[1nickt]: pryrt I am creating a Type to check valid user IDs, which must be a whole number greater than or equal to zero. I would like to disallow 1.0 but because of this behaviour, by the time it is checked by the constraint, it *is* an Int.
[LanX]: should this be considered? Re: Parsing .txt into arrays

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2017-05-24 20:09 GMT
Find Nodes?
    Voting Booth?