I have a log file that appends new logs as the program runs on different days. Each iteration there will be a new Product Version and Launch Switch. I need the Product Version: [0-9-]*and Launch Switch: \w* from each iteration as a tuple.
Currently I am doing this:
ver = re.findall(r'(?<=Product Version: )[0-9.]*', s)
launch = re.findall(r'(?<=Launch Switch: )\w*', s)
Then later I’m iterating through ver and launch to create the tuples. It works, but it’s not pretty and I’m sure there’s a more Pythonic way of doing this.
You can use multiple capturing groups within your regex pattern;
re.findallwill then return them as a tuple. For example:From the
re.findalldocs: