regular expression reverse match?

Ron Adam radam2 at tampabay.rr.com
Tue Oct 28 22:45:28 EST 2003


Is it possible to match a string to regular expression pattern instead
of the other way around?

For example,  instead of finding a match  within a string,  I want to
find out, (pass or fail), if a string is a partial match to an re.

Given an  re of   'abcd and a bunch of other stuff'  

This is what i'm looking for:

	string  /  result
 	'a'  /  pass
	'ab' /  pass
	'abc'  / pass
	'abd'  /  fail
	'aaaa'  /  fail
	'abcd and a bunch of other stuff and then some'  /  fail

Is there a way to form a regular expression that will do this?  

I'm hoping to use more complex regular expressions than this.   But
the left to right precedence will still be the same.

_Ron Adam








More information about the Python-list mailing list