On 8/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi, > I'm looking for the best way to check if regular expression return > true (it's mean - there is a match). for example, i want "if" that > check if this regular expression: .*born.*to.* has a match. > > What's the way to do that simply? > How about
import re re.match(".*born.*to", "This is a test") re.match(".*born.*to.*", "This test was born so that it worked too.") (Try these at the python prompt) The first call to 're.match()' returns 'None' which will fail an if test. The second one returns a match object, which evaluates to TRUE in an if test. --wpd -- http://mail.python.org/mailman/listinfo/python-list