How do I find possible matches using regular expression?

Andy icetortoise at gmail.com
Thu Nov 23 05:02:18 EST 2006


The problem is the input will be much more complex than the example, it
could be something like "30 minutes later" where any string starting
with a number is a possible match.


Paul McGuire 寫道:

> "Andy" <icetortoise at gmail.com> wrote in message
> news:1164272307.978986.158810 at l39g2000cwd.googlegroups.com...
> > Hi there,
> >
> > I'm trying to do some predicting work over user input, here's my
> > question:
> >
> > for pattern r'match me', the string 'no' will definitely fail to match,
> > but 'ma' still has a chance if user keep on inputting characters after
> > 'ma', so how do I mark 'ma' as a possible match string?
> >
> > Thanks a lot,
> >
> > Andy
> >
> Maybe .startsWith might be more useful than re.match, since you are
> predicting user input based on characters that have been typed so far.
> 
> -- Paul




More information about the Python-list mailing list