I have something like this:
Othername California (2000) (T) (S) (ok) {state (#2.1)}
Is there a regex code to obtain:
Othername California ok 2.1
I.e. I would like to keep the numbers within round parenthesis which are in turn within {} and keep the text "ok" which is within (). I specifically need the string "ok" to be printed out, if included in my lines, but I would like to get rid of other text within parenthesis eg (V), (S) or (2002).
I am aware that probably regex is not the most efficient way to handle such a problem.
Any help would be appreciated.
EDIT:
The string may vary since if some information is unavailable is not included in the line. Also the text itself is mutable (eg. I don't have "state" for every line). So one can have for example:
Name1 Name2 Name3 (2000) (ok) {edu (#1.1)}
Name1 Name2 (2002) {edu (#1.1)}
Name1 Name2 Name3 (2000) (V) {variation (#4.12)}

2.1here, it would be much difficult if we want to take in account multiple instances of it, for example{state (#2.1) yellow (33)}. The problem with this kind of situations is the following: You have "theoretically" two ways to solve it: 1) Look ahead and behind if there is{}, the problem is that look behinds must be of fixed length in most regex flavors (same for python) 2) Use subgroup matching, something like\{(?:.*?\((\w+)\).*?)+\}which isn't available in most regex flavors. Thus I think your mission is impossible with pure regex power.