Regex matching - why does this not match and return None?

后端 未结 1 1529
轻奢々
轻奢々 2020-12-22 00:35

I don\'t understand why this simple regex match does not return a match object. It returns None what am I doing wrong?

I\'m a total newby(started yesterday) and want

相关标签:
1条回答
  • 2020-12-22 00:48

    Because you should be passing the re.I to compile(), not match().

    >>> pattern = re.compile(r'^9', re.I)
    >>> a=pattern.match(teststring)
    >>> print a
    <_sre.SRE_Match object at 0x1140168>
    
    0 讨论(0)
提交回复
热议问题