Python regular expressions return true/false

前端 未结 6 1213
情歌与酒
情歌与酒 2020-12-23 02:44

Using Python regular expressions how can you get a True/False returned? All Python returns is:

<_sre.SRE_Match object at ...>         


        
6条回答
  •  执笔经年
    2020-12-23 03:20

    You can use re.match() or re.search(). Python offers two different primitive operations based on regular expressions: re.match() checks for a match only at the beginning of the string, while re.search() checks for a match anywhere in the string (this is what Perl does by default). refer this

提交回复
热议问题