Please help understand why r'\b\w+(?=\d)(?=[A-Z])'
does not match Python3A.
It says r'\b\w+(?=\d)(?=[A-Z])'
search for words followed by a digit and then by a capital letter. Python3A consists of a word Python
followed by a digit 3
and a capital letter A
. If the statement is correct, then it should match Python.
>Solution :
It doesn’t match because you have two lookaheads in the same place, one of which asserts a number, and the other asserts a capital letter. Since there is no overlap between those, one of them can’t be true and so the match fails. What you need is just a single lookahead for a digit followed by a capital letter:
\b\w+(?=\d[A-Z])
Regex demo on regex101