Number of regex matches

前端 未结 6 1871
长情又很酷
长情又很酷 2020-12-05 03:49

I\'m using the finditer function in the re module to match some things and everything is working.

Now I need to find out how many matches

6条回答
  •  伪装坚强ぢ
    2020-12-05 04:21

    If you know you will want all the matches, you could use the re.findall function. It will return a list of all the matches. Then you can just do len(result) for the number of matches.

提交回复
热议问题