I need help analyzing user input in python using a mixture of regex and repeating the result from regex. An example input looks like this:
KeylessBuy=f and not (Feedback.color = green or comment.color=green)
and not "BIN State".color = white and comment="got it right"
The result of the separation should be:
KeylessBuy=f
Feedback.color = green
comment.color=green
"BIN State".color = white
comment="got it right"
So, we select only those parts that directly surround the "=" sign. I tried (including):
r'(\w+\s{0,}(?<!=)={1,2}(?!=)\s{0,}\w+)'
r'|("(.*?)"\s{0,}(?<!=)={1,2}(?!=)\s{0,}\w+)'
r'|("(.*?)"\s{0,}(?<!=)={1,2}(?!=)\s{0,}"(.*?)")'
r'|(\w+\s{0,}(?<!=)={1,2}(?!=)\s{0,}"(.*?)")'
r'|(\w+\s{0,}\.\w+\s{0,}(?<!=)={1,2}(?!=)\s{0,}"(.*?)")',
This only "almost" gives the correct answer. Any help is much appreciated! Thank you so much. Mark
source
share