I want to split a string by boundaries between non-repeating characters with Python. I wrote this regex:
(?<=(.))(?!\\1)', string)
So I expecting "aaab447777BBBBbbb" will be splitted to ['aaa', 'b', '44', '7777', 'BBBB', ''bbb]
I used the same regex in Java and got the desired result. Unfortunately, this does not work in Python. When I try
re.split('(?<=(.))(?!\\1)', string)
the result is
['aaa', 'a', 'b', 'b', '44', '4', '7777', '7', 'BBBB', 'B', 'bbb', 'b', '']
When I do
re.findall('(?<=(.))(?!\\1)', string)
returns
['a', 'b', '4', '7', 'B', 'b']
Why doesn't Python understand the regular expression that Java understands and how to solve the problem in Python?