You can use regex (?<=\(_S)((.|\n)*?)(?=S_\))
for getting string inside (_S
and S_)
Similarly you can use regex (?<=\(_B)((.|\n)*?)(?=B_\))
for getting string inside (_B
and B_)
To match these two , you can use :
(?:(?<=\(_S)((?:.|\n)*?)(?=S_\)))|(?:(?<=\(_B)((?:.|\n)*?)(?=B_\)))
To match string that are not enclosed in brackets , you can use something like this :
(((?:^)|(?<=\)))(?:[^(])*)