From the following string:
s = "ABCD {DB_any_alphanumeric_character\} ABCD {DB_any_alphanumeric_character}.TABLE ABCD"
I would like to match only {DB_any_alphanumeric_character}.TABLE. So the starting term is {DB_ and the end term is .TABLE. My difficulties arise since there are two {DB_ in the string.
How can I make it match only from the second {DB_ until .TABLE?
I feel like this can't be a very complicated regex, but despite reading through dozens of regex related stackoverflow questions and tutorials (e.g. https://regex101.com, https://regexone.com/lesson/line_beginning_end, ...) online, I fail.
Here are just two of my unsuccessful attempts:
exp = re.search(r"^{DB\w*TABLE$", s)
It returns None. They way I see it, it should return a string that starts with {DB followed by zero or more repititions of any alphanumeric character and end with TABLE.
Another attempt:
test = re.search(r"{DB(.+?).TABLE", s)
This returns {DB_ABCD\\} ABCD {DB_ABCD}.TABLE, which is exactly what I don't want.