Hello,
I still learn to use regex, but have still some problems, and can't go further without your help. This time I have a SQL like this:
insert into DataWarehouse.dbo.Users (Forename, SurName) values ('John', 'Dark')
I would like to capture 'DataWarehouse' and 'Users' that is database name and table name when query matches like below, so if query is a Insert query:
insert into <database_name>.dbo.<table_name>
database_name and table_name can contain only letters. It's possible that one query has multiple times insert into like this:
insert into DataWarehouse.dbo.Users (Forename, SurName) values ('John', 'Dark')
insert into DataWarehouse.dbo.Users (Forename, SurName) values ('Jack', 'Black')
I figured out this regex:
insert\\sinto\\s(?<Database>\\w+)\\.\\w+\\.(?<Table>\\w+)
Unfortunately it doesn't capture Database and Table at all.
Edit: I've found this one here:
http://regexadvice.com/forums/thread/35203.aspx
It's similar but matches 'insert into <table_name>' and i would like to match 'insert into <database_name>.dbo.<table_name>. It's fully typed name of a table. First part is database name, second is schema name and third is table name.
Edit: Ok, solved:
(?<Insert>INSERT INTO\\s+)(?<Database>\\w+)\\.(?<Schema>\\w+)\\.(?<Table>\\w+)
Greetings!