Re: creating an (inefficent) alternating regular expression from a list of options

2008-09-18 Thread metaperl.com
On Sep 9, 12:42 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > you may also want to do re.escape on all the words, to avoid surprises > when the choices contain special characters. yes, thank you very much: import re def oneOf(s): alts = sorted(s.split(), reverse=True) alts = [re.esca

Re: creating an (inefficent) alternating regular expression from a list of options

2008-09-18 Thread metaperl.com
On Sep 9, 9:23 am, [EMAIL PROTECTED] wrote: >     >> I really dont care if theexpressionis optimal. So the goal is >     >> something like: > >     >> vowel_regexp = oneOf("a aa i ii u uu".split())  # yielding r'(aa|a|uu| >     >> u|ii|i)' > >     >> Is there a public module available for this purp

Re: creating an (inefficent) alternating regular expression from a list of options

2008-09-09 Thread Fredrik Lundh
Larry Bates wrote: vowel_regexp = oneOf("a aa i ii u uu".split()) # yielding r'(aa|a|uu| u|ii|i)' Is there a public module available for this purpose? Perhaps I'm missing something but your function call oneOf(...) is longer than than actually specifying the result. You can certainly writ

Re: creating an (inefficent) alternating regular expression from a list of options

2008-09-09 Thread George Sakkis
On Sep 9, 9:12 am, "metaperl.com" <[EMAIL PROTECTED]> wrote: > Pyparsing has a really nice feature that I want in PLY. I want to > specify a list of strings and have them converted to a regular > expression. > > A Perl module which does an aggressively optimizing job of this is > Regexp::List > -

Re: creating an (inefficent) alternating regular expression from a list of options

2008-09-09 Thread Nick Craig-Wood
metaperl.com <[EMAIL PROTECTED]> wrote: > Pyparsing has a really nice feature that I want in PLY. I want to > specify a list of strings and have them converted to a regular > expression. > > A Perl module which does an aggressively optimizing job of this is > Regexp::List - > http://search.c

Re: creating an (inefficent) alternating regular expression from a list of options

2008-09-09 Thread Marc 'BlackJack' Rintsch
On Tue, 09 Sep 2008 08:19:04 -0500, Larry Bates wrote: >> I really dont care if the expression is optimal. So the goal is >> something like: >> >> vowel_regexp = oneOf("a aa i ii u uu".split()) # yielding r'(aa|a|uu| >> u|ii|i)' >> >> Is there a public module available for this purpose? >> >>

Re: creating an (inefficent) alternating regular expression from a list of options

2008-09-09 Thread skip
>> I really dont care if the expression is optimal. So the goal is >> something like: >> vowel_regexp = oneOf("a aa i ii u uu".split()) # yielding r'(aa|a|uu| >> u|ii|i)' >> Is there a public module available for this purpose? Check Ka-Ping Yee's rxb module: http://lfw

Re: creating an (inefficent) alternating regular expression from a list of options

2008-09-09 Thread Larry Bates
metaperl.com wrote: Pyparsing has a really nice feature that I want in PLY. I want to specify a list of strings and have them converted to a regular expression. A Perl module which does an aggressively optimizing job of this is Regexp::List - http://search.cpan.org/~dankogai/Regexp-Optimizer-0.1

creating an (inefficent) alternating regular expression from a list of options

2008-09-09 Thread metaperl.com
Pyparsing has a really nice feature that I want in PLY. I want to specify a list of strings and have them converted to a regular expression. A Perl module which does an aggressively optimizing job of this is Regexp::List - http://search.cpan.org/~dankogai/Regexp-Optimizer-0.15/lib/Regexp/List.pm