Here are two very basic examples of the problem that I am currently encountering in my work:
import re
type(re.search('(Bob)(.*)(Builder)', "Bob the Builder" , re.IGNORECASE))
returns _sre.SRE_Match
and
import re
type(re.search('(Bob)(.*)(Builder)', "the Builder" , re.IGNORECASE))
returns NoneType
. How can I test for the condition whether the data type is _sre.SRE_Match
or NoneType
? When I try implementing the code
import re
type(re.search('(Bob)(.*)(Builder)', "the Builder" , re.IGNORECASE)) is None
it returns False
when it should be returning True
. What am I doing incorrect here? Thank you!
Aucun commentaire:
Enregistrer un commentaire