[Tutor] Regex Ordering

David Perlman dperlman at wisc.edu
Tue Jul 24 07:07:30 CEST 2007


Then maybe you could write a regex that matches every regex that does  
not match itself.

ha!  sorry, couldn't resist.

On Jul 23, 2007, at 11:29 AM, Bill Campbell wrote:

> On Mon, Jul 23, 2007, James Hartley wrote:
>> On 7/23/07, Shidan <shidan at gmail.com> wrote:
>>> I'm looking for a Python module that provides methods for ordering
>>> regexes based on
>>> how general they are ( how much they match). Do I have to write it
>>
>> Your question is relative.  Classifying which regular expression is
>> more general depends upon the other regular expressions used in
>> comparison along with the specific input.  As you change input &
>> regular expressions, the ordering will change.
>
> As a first cut, one might sort the regular expression strings in
> reverse order such that the longer strings are tested first.
>
> Bill
> --
> INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
> URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
> FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206)  
> 236-1676
>
> Virtually everything is under federal control nowadays except the
> federal budget.
>     -- Herman E. Talmadge, 1975
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

--
-dave----------------------------------------------------------------
All I ask is that the kind of unsolvable that it turns out to be has
respectable precedents.  -Jerry Fodor




More information about the Tutor mailing list