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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

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