1

I need a RegEx to get name of table, keys and every attribute from CREATE TABLE statement... for example: Here I create this table, and i need to get all attributes

​CREATE
​  TABLE KATEGORIE
​  (
​    id INTEGER NOT NULL ,
​    nazev NVARCHAR (20) NOT NULL ,
​    cena INTEGER NOT NULL ,
​    CONSTRAINT KATEGORIE_PK PRIMARY KEY CLUSTERED (id)
​WITH
​  (
​    ALLOW_PAGE_LOCKS = ON ,
​    ALLOW_ROW_LOCKS  = ON
​  )
​  ON "default"
​  )
​  ON "default"
​GO

So far I have this: \s*CREATE\s*TABLE\s*(.*)\s*\(\s*(.*\s*) ; but this wont work, because there is always different number of attributes, I need to get all of them and end when word "WITH" or ')' shows up. Thanks for any help.

1

1 Answer 1

1

I figured it out, thanks for help. I edited regex, for taking anything before ',' and i iterate through it, then i get last line.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.