I need to parse (extract data - don't need to replace anything).
Test string: MAIN_HEADER:(ANOTHER_HEADER([DUMDUM:(BAH_123),OOPS,YEAH:(GAGA)]))
need to output:
First component:
MAIN_HEADER- only caps alpha and underscoreSecond component:
ANOTHER_HEADER:([DUMDUM:(BAH_123),OOPS,YEAH:(GAGA)])- caps alpha, numbers, square and round brackets, commas, colons in any combination
I can extract second component with ^\(([a-zA-Z0-9_:,\(\)\[\]]*)\)$ but I don't know how to do 2 different matches to split components.
You may use this regex to extract 2 capture group as desired:
RegEx Demo
RegEx Details:
^:([A-Z_]+): Match 1+ of uppercase letters or_in capture group #1:\s*: Match:followed by 0 or more whitespaces\(: Match literal(([][A-Z0-9_(),:]+): Match 1+ of uppercase letters or_or digits or(or)or[or]or,or:in capture group #2\): Match literal)