Regex match even number of letters

后端 未结 8 1100
没有蜡笔的小新
没有蜡笔的小新 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:08

    First of all, note that /A*/ matches the empty string.

    Secondly, there are some things that you just can't do with regular expressions. This'll be a lot easier if you just walk through the string and count up all occurences of the letter you're looking for.

提交回复
热议问题