A
A
Animkim2016-04-21 19:38:59
Python
Animkim, 2016-04-21 19:38:59

Python and regex where is the error?

data = re.findall(r'[A-Z]([a-z])[A-Z]', 'aaaaBBzDDvSbG')

According to my idea, all small letters that are surrounded by large ones (''zvb") should be collected, if the pattern intersects with another pattern, then the letter is skipped, this should not happen. I don’t understand how to make it work with intersections, tell me the code and if you can advise something on regular expressions, I just can't understand them.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2016-04-21
@Animkim

data = re.findall(r'(?<=[AZ])([az])[AZ]', 'aaaaBBzDDvSbG')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question