Python regex string matching?

后端 未结 2 1380
再見小時候
再見小時候 2020-11-28 13:29

I\'m having a hell of a time trying to transfer my experience with javascript regex to Python.

I\'m just trying to get this to work:

print(re.match(         


        
2条回答
  •  春和景丽
    2020-11-28 13:56

    re.match implicitly adds ^ to the start of your regex. In other words, it only matches at the start of the string.

    re.search will retry at all positions.

    Generally speaking, I recommend using re.search and adding ^ explicitly when you want it.

    http://docs.python.org/library/re.html

提交回复
热议问题