Regex string doesn't match

前端 未结 3 1451
独厮守ぢ
独厮守ぢ 2020-12-21 04:31

I\'m having trouble matching a digit in a string with Python. While it should be clearly matched, It doesn\'t even match [0-9] [\\d] or just

相关标签:
3条回答
  • 2020-12-21 04:54

    Use re.search instead of re.match.

    0 讨论(0)
  • 2020-12-21 04:58

    Read the documentation: http://docs.python.org/2/library/re.html#re.match

    If zero or more characters at the beginning of string

    You want to use re.search (or re.findall)

    0 讨论(0)
  • 2020-12-21 05:08

    re.match is "anchored" to the beginning of the string. Use re.search.

    0 讨论(0)
提交回复
热议问题