re模糊查询

来源:互联网 发布:数据库字段注释 编辑:程序博客网 时间:2024/04/30 23:54


import redef testSearchAndMatch():  s1="helloworld, i am 30 !"    w1 = "world"  m1 =  re.search(w1, s1)    if m1:    print("find : %s" % m1.group())      if re.match(w1, s1) == None:    print("cannot match")      w2 = "helloworld"  m2 = re.match(w2, s1)  if m2:    print("match : %s" % m2.group())testSearchAndMatch()