Result should return list which contains letter a to c followed by another character
Text is aabbcc I would expect it return ['a', 'a', 'b', 'b', 'c']
import re
text = 'aabbcc'
result = re.findall(r'([a-c]).', text)
print(result)
but it returns ['a', 'b', 'c']
Use a non-capturing lookahead ([a-z](?=.)). This is basically the same as what you had, but doesn't capture the next character.
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