Sample input= “words and stuff %%r:livingroom%% words and stuff”
I would like a python regex snippet to return “livingroom” in this case, or some other value to indicate no match.
Yes, this the first part of my kludgy way of indicating if an Indigo Device is assigned to a room, using the “Notes” field of the Device.
Edit: Never mind, i got something to work, but am certainly open to better ideas:
- Code: Select all
import re
text = "words words %%r:den%% words"
room = re.search('%%r:(.*?)%%', text)
print(room.group(1))
Edit 2:
Silly me, i realized this could easily be achieved with
- Code: Select all
if “%%r:den%%” in text:
print(“den”)