A Regexp Assembler/Compilerby PetaMem (Priest)
|on Jun 19, 2002 at 14:56 UTC||Need Help??|
PetaMem has asked for the
wisdom of the Perl Monks concerning the following question:
Hello Regexp Alcolytes!
Disclaimer: Don't point me to Math::Roman, read the node. :-)
Probably the title of this node is horribly wrong, so I try to explain my need in more detail. Let's say you have a set of regexps. Now lets say you are testing each of these regexps against a string to see if it matches or not. Something like this Roman Numeral Thingie. Meanwhile it looks slightly better:
And now there is a subroutine to answer the question if a given string actually is a roman numeral:
So lets return to the question. Given a set of regexps and given a wanted logical concatenation (lets start with AND,OR) of these regexps, is there any mechanism to create a smaller, more eficient set of regexps that will have the same effect?
I feel remembered to a similar problem in boolean logic, where you apply some de morgan, do transformations on complex boolean formulae and - sometimes - end up with smaller nifty formulae. Thought same should be possible with regexps.
Thoughts? Answers? Meditation?