I am trying to split a SQL Query script, and on a create table, I only want the contents inside the outermost parenthesis, while ignoring any parenthesis inside, which are mainly describing maximum characters for a column type.
Here is a sample of my query:
CREATE TABLE IF NOT EXISTS %SCHEMA%.business (
id UUID NOT NULL,
name VARCHAR(50) NOT NULL,
DBA VARCHAR(50),
isactive BOOL NOT NULL DEFAULT TRUE,
isdeleted BOOL NOT NULL DEFAULT FALSE,
createdon TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL
)
WITH (OIDS = FALSE)
I want to get back everything inside that describe the columns. I have tried these
\(([^\)]*)\)
stops at the first (50), and reads the other (50) and (6), but not anything else, and doesn't reach the end of that outside parenthesis.
\((\d+)\)
This will only read the inside parenthesis, which could be useful later, but I only get back the two (50)'s and the (6).
What regular expression will capture all of the inside of that parenthesis? Even if it does capture more, I can always remove the excess strings through code later.