I'd like to match a string with the following conditions
- must start with an A
- followed by any count of anything unless it's two consecutive upper case letter
- followed by a number (which should be captured)
A bcd 1  should match and capture 1
Abcd1  should match and capture 1
A bcd   should not match because there is no number
A BCd 1  should not match because there is a capital C between the A and the number
A bcd 1 EF should match because 1 is before the EF
I came up with
A(?!.*[A-Z]{2})+?.*(\d+)
but that does not work for the last use case because the negative lookahead goes beyond the 1
Here is a playground https://regex101.com/r/1zRCrp/3
 
     
     
    