python - Regex match even number of letters -


i need match expression in python regular expressions matches number of letter occurrences. example:

 aaa        # no match aa         # match fsfaaaasdf # match safa       # match sdaaewasa  # match aeaia      # no match 

an number of should match.

try regular expression:

^[^a]*((aa)+[^a]*)*$ 

and if as don’t need consecutive:

^[^a]*(a[^a]*a[^a]*)*$ 

Comments

Popular posts from this blog

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -

openssl - Load PKCS#8 binary key into Ruby -