I am trying to split a string in python before a specific word. For example, I would like to split the following string before "path:".
- split string before
"path:" - input:
"path:bte00250 Alanine, aspartate and glutamate metabolism path:bte00330 Arginine and proline metabolism" - output:
['path:bte00250 Alanine, aspartate and glutamate metabolism', 'path:bte00330 Arginine and proline metabolism']
I have tried
rx = re.compile("(:?[^:]+)")
rx.findall(line)
This does not split the string anywhere. The trouble is that the values after "path:" will never be known to specify the whole word. Does anyone know how to do this?