regular expression reverse match?
radam2 at tampabay.rr.com
Wed Oct 29 06:47:49 CET 2003
On Tue, 28 Oct 2003 21:19:56 -0600, Jay Dorsey <jay at jaydorsey.com>
> >>> matcher = "abcd and a bunch of other stuff"
> >>> phrases = ["a", "ab", "abc", "abd", "aaaa", "abcd and a bunch of
>other stuff and then some"]
> >>> for phrase in phrases:
>... if phrase == matcher[:len(phrase)]: print "pass"
>... else: print "fail"
Hi Jay, That was an overly simple example I gave I think. The
'pattern' will in most case not be just a simple string. And I'll
only be testing on one string at a time as it forms.
It's an interactive input routine. So as the person types, I want to
test the buffer and accept or reject each key according to the
pattern. Pass or fail.
This method would work though if it's possible to expand a regular
expression out to a string of single matching re characters I think.
Then it would be a matter of doing re.match('ibuffer',
I just don't know enough yet, but am learning quickly though,
More information about the Python-list