Regex match even number of letters

后端 未结 8 1101
没有蜡笔的小新
没有蜡笔的小新 2020-12-06 05:35

I need to match an expression in Python with regular expressions that only matches even number of letter occurrences. For example:

AAA        # no match
AA                


        
8条回答
  •  南笙
    南笙 (楼主)
    2020-12-06 06:07

    This searches for a block with an odd number of A's. If you found one, the string is bad for you:

    (?

    If I understand correctly, the Python code should look like:

    if re.search("(?

提交回复
热议问题