I would like to extract the substring from the string, such as
Case 1:
text = "some_txt" # → some_txt
Case2:
text = "[info1]some_txt" # → some_txt
Case3:
text = "[info1][info2] some_text" # → some_txt
Case4:
text = "[info1][info2] some_text_with_[___]_abc" # → some_text_with_[___]_abc
What I did was
match = re.search("^\[.+\] (.*)", text)
if match:
result = match.group(1)
It works okay except case 4, which gives abc
only. I want to get some_text_with_[___]_abc
instead.
Any help will be greatly appreciated.