Reputation: 29387
That is a regex that would match:
stringAstring => A
stringAAAstring => AAA
stringAAAAAstring => AAAAA
[... and so on...]
But wouldn't match:
stringAAstring => null
stringAAAAstring => null
stringAAAAAAstring => null
Upvotes: 1
Views: 836
Reputation: 170158
If the regex flavor you're using supports look-arounds, this should work:
(?<!A)(AA)*A(?!A)
(AA)*A
matches an odd number of 'A'
s and the (?<!A)
asserts that it should not be preceded by an 'A'
and (?!A)
asserts it should not be followed by an 'A'
.
Upvotes: 4