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 # match fsfaAAasdf # match sAfA # match sdAAewAsA # match AeAiA # no match
An even number of As SHOULD match.
Try this regular expression:
^[^A]*((AA)+[^A]*)*$
And if the A
s don’t need to be consecutive:
^[^A]*(A[^A]*A[^A]*)*$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With