I been struggling to find a Regex that help me match 3 different strings only if they aren't inside parentheses, but so far I have only managed to match it if it's right next to the parentheses, and in this specific situation it doesn't suit me.
To clarify I need to match the Strings "HAVING", "ORDER BY" and "GROUP BY" that aren't contained in any parentheses, no matter if the parentheses contains more than just the string.
In that case:
Select *
from some_table
group by something;
Should match, but:
Select *
from(
Select *
from some_other_table
group by something_else
)
or
Select this, and_this
from(
Select *
from some_other_table
having some_condition
)
shouldn't.
I'm not an expert in Javascript Regex, so any help you could give me would be greatly appreciated.