The Opposite of re match
matt_gerrans at hp.com
Thu Aug 22 01:43:32 CEST 2002
Is there some re trick to find out specificaly why an re *doesn't* match?
I have a script which tests user input on a collection of regular
expressions; if it fails all of them the input is rejected, but I'd like to
be able to display a useful message like "You entered 'abc_1q23.ext' which
is pretty close to the 'aaa_nnn.ext' format, but you cannot have a letter in
the number field." Since the re test will simply return None for all the
available format choices, there is no object to work with, of course.
Trying to anticipate every possible zany form of input that may arrive could
be a pretty big task, too.
More information about the Python-list