regular expression to capture content of a group and reuse them
09:01 23 Sep 2017

How can I write a regular expression to replace

VALUES ('some text') 

with

SELECT * FROM (SELECT 'some text') AS tmp...

Basically, I have an input file, with multiple Insert statements. I want to use Regex to convert each insert statement into a IF NOT EXISTS then INSERT Statement (and run in in MySQL).

So, this is my input:

 INSERT INTO table_listnames (name, address, tele) VALUES ('Rupert', 'Somewhere', '022') 

and this is the desired output:

INSERT INTO table_listnames (name, address, tele)
SELECT * FROM (SELECT 'Rupert', 'Somewhere', '022') AS tmp
WHERE NOT EXISTS (
    SELECT VersionNumber FROM ReleaseInfo WHERE VersionNumber = '1.0.0.1'
) LIMIT 1;
c# regex