I am extracting results from a (poorly coded) python file, a sample of what I am looking at is as follows:
if (name == "wheat"):
return "WHEAT"
if (name == "enchanted bread") or (name == "ebread") or (name == "bread"):
return "ENCHANTED_BREAD"
if (name == "hay bale") or (name == "haybale"):
return "HAY_BLOCK"
if (name == "enchanted hay bale") or (name == "ebale") or (name == "ehayblock"):
return "ENCHANTED_HAY_BLOCK"
if (name == "tightly-tied hay bale") or (name == "tightly tied hay bale"):
return "TIGHTLY_TIED_HAY_BALE"
I am looking to make a .json parallel array using this information to index it, following the following format "ENCHANTED_BREAD": ["enchanted bread", "ebread", "bread"]
I am trying to create a regex to find all the aliases of the return value. So far I thought about using the following REGEX as I already extracted the return values and organised them as keys:
=="(.*?)"
but the issue with it is that I won't be able to "group" the values to assign multiple to a single key. Since the values corresponding to the same key are on the same line it is probably the way to go.
What can I use in regex to be able to group the regex matches per line?
Thank you for your help.