def find_and_sep(inputstr, thing_to_find): #thing to find is a string that is a regular expression #finds thing_to_find and returns tuple of the rest (before, thing, after) inputstr.strip() #match it m=re.match(thing_to_find, inputstr) #match first instance if(m==None): return "" start = inputstr[:m.start()] mid = inputstr[m.start():m.end()] end = inputstr[m.end():] tuple_x = start,mid,end return tuple_x
my problem is when I give it
ins="blahCOMblah" tmp=find_and_sep(ins, "(COM)?")
It only puts the whole thing in the last of the 3tuple
I want it to split into <blah,COM,blah>
Anyone know how to fix this?