Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > minimalist regular expression

Reply
Thread Tools

minimalist regular expression

 
 
borges2003xx@yahoo.it
Guest
Posts: n/a
 
      08-25-2005
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

 
Reply With Quote
 
 
 
 
Trent Mick
Guest
Posts: n/a
 
      08-25-2005
[(E-Mail Removed) 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

--
Trent Mick
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
borges2003xx@yahoo.it
Guest
Posts: n/a
 
      08-25-2005
very nice

 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      08-25-2005
"(E-Mail Removed)" <(E-Mail Removed)> 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?
> thanx in advance


length? (define minimal) .

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

 
Reply With Quote
 
borges2003xx@yahoo.it
Guest
Posts: n/a
 
      08-26-2005
the shortest description in regex way

 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      08-26-2005
(E-Mail Removed) 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?
> thanx in advance


m//;

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

Paul Lalli

 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      08-26-2005
"(E-Mail Removed)" <(E-Mail Removed)> wrote:

> the shortest description in regex way


Which is? Oh, and please quote the previous message and author. Reply under
the part you are replying too, etc. Even with Google this is possible.

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

 
Reply With Quote
 
Paul McGuire
Guest
Posts: n/a
 
      08-26-2005
Google for "optimized regexp" returns:
http://laurent.riesterer.free.fr/reg...ke-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

 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      08-26-2005


Paul Lalli wrote:
>
> m//;
>
> it matches everything.


Not in Perl it doesn't.

 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      08-26-2005
Brian McCauley wrote:
> Paul Lalli wrote:
> >
> > m//;
> >
> > it matches everything.

>
> Not in Perl it doesn't.


Sure it does.... provided you haven't tried matching anything else
beforehand...

Paul Lalli

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very Simple, Minimalist Technique For OOP in C... Chris Thomasson C Programming 10 06-24-2007 07:53 PM
minimalist regular expression borges2003xx@yahoo.it Perl Misc 9 08-29-2005 10:42 AM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM
Minimalist executable Sam C Programming 3 08-15-2003 11:32 PM
Use Cases -- A minimalist's View Uncle Bob (Robert C. Martin) Java 0 07-02-2003 02:45 PM



Advertisments