> for pattern in thelist:
>    regex=re.compile(pattern)
>    if regex.match('24110'):
>        the_pattern = pattern
>        .
>        .
>        sys.exit(0)
>
> but in this case it will pick thelist[2] and not the list[3] as I
wanted to,
> how can I have it pick the pattern that describes it better from the
list.

Define 'better'.
Both regex describe it equally well, how is Python supposed to
know which one is 'better'? You have to tell it by ordering your
list according to your idea of better, usually meaning most
specific test first.

Alan G

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to