[Tutor] Regex Ordering
Bill Campbell
bill at celestial.net
Mon Jul 23 18:29:30 CEST 2007
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
More information about the Tutor
mailing list