minimalist regular expression

B

borges2003xx

Exists some tool, programs or some able to compute the minimal regular
expression, namely ,taking a series of regular exoression, the minimal
one that makes the same matching?
thanx in advance
 
T

Trent Mick

[[email protected] wrote]
Exists some tool, programs or some able to compute the minimal regular
expression, namely ,taking a series of regular exoression, the minimal
one that makes the same matching?

def get_minimal_regex(*regexes):
return ".*"

:) Or, slightly less smart-ass-y:

def get_not_really_minimal_regex(*regexes):
return "(" + "|".join(regexes) + ")"

Trent
 
J

John Bokma

Exists some tool, programs or some able to compute the minimal regular
expression, namely ,taking a series of regular exoression, the minimal
one that makes the same matching?
thanx in advance

length? (define minimal) :-D.
 
P

Paul Lalli

Exists some tool, programs or some able to compute the minimal regular
expression, namely ,taking a series of regular exoression, the minimal
one that makes the same matching?
thanx in advance

m//;

it matches everything. Perhaps you need to better define your problem
statement. Sample input, desired output...

Paul Lalli
 
P

Paul McGuire

Google for "optimized regexp" returns:
http://laurent.riesterer.free.fr/regexp/make-regexp.html
http://search.cpan.org/~dankogai/Regexp-Optimizer-0.15/

There are several more links, but all appear to be written in languages
other than Python. Perhaps you could port one of them.

It also seems that a similar thread came up here recently, at least in
the special form of converting a list of words to a single regexp. In
general, this seems to be a difficult problem, not only to implement,
but to test. At least the conversion of a list of words to a single
regexp is easily tested against the input set, although as some of the
other clever posters have noted, it is possible to create a regexp that
is *too* matchable.

-- Paul
 
B

borges2003xx

Whenever I ask a match in a string for(a{3,}b and match for (a{1,}, the
first is implicit second: ab is implicit in a.*;automatically
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top