Take for example the following lines
0.714285714285714285714285714285714285714285
0.111111111111111111111111111111111111111111
0.166666666666666666666666666666666666666666
I want to find a substring repeating repetition for each.
714285
1
6
How to do this in python. Using regex is fine, I tried the following:
import re
testString = "0.714285714285714285714285714285714285714285"
print(re.search(r"(.+)\1", testString).group(1))
This gives me the (wrong) conclusion:
714285714285714285
It should be 7814285
How to fix it? Is there a way to improve my regex or regex is the wrong tool for this job? Maybe python has an awesome built-in for this? Should I use this with or without regex?
EDIT Before posting a response using a test case
0.0022271714922048997772828507795100222717149220489977728285077951002227171492204899777282850779510022
He must return 00222717149220489977728285077951