I'm wondering if its possible to use string substitution along with the python re module?
For example I'm using optparse and have a variable named options.hostname which will change each time the user executes the script.
I have the following regex matching 3 strings in each line of the log file.
match = re.search (r'^\[(\d+)\] (SERVICE NOTIFICATION:).*(\bCRITICAL)', line)
I want to be able to perform string substitution by matching options.hostname as the last match group however I can't get any variations to work. Is this possible?
match = re.search (r'^\[(\d+)\] (SERVICE NOTIFICATION:).*(\bCRITICAL).*(s%), line) % options.hostname