I have the string "open this and close that" and I want to obtain "open this and" and "close that".  This is my best attempt:
>>>print( re.split(r'[ ](?=(open|close)+)', "open this and close that") )
['open this and', 'close', 'close that']
I'm using Python 3.4.
Split string with multiple delimiters in Python replaces the triggers. I need them, the script has to know if I want to turn off or on a light, and not only which light is.
 
     
     
    