I want to match or with the string I obtain and group the result based on the times or occurs.
My input will be like:
a or b*~c or 27*y or 5*~b
so my output should be:
a, b*~c, 27*y, 5*~b
My code works if there are exactly 3 or, but returns [] otherwise.
I am new to python and I don't understand exactly how the pattern must be given to the compile function.
import re
input = raw_input(" ")
ans = re.compile(r'(.*) or (.*) or (.*) or (.*)')
print re.findall(ans, input)
str.split('or').re.splitis expected to be slower,