Find and replace using regular expression, group capturing, and back referencing
SQL Server Management Studio engine uses {
and }
to "tag" expressions:
SELECT {.+} FROM {.+}
When you combine this with the \1 \2
replacement expression, you get the expected result:
First Table1
Second Table2
Third Table3
VS Regex reference page explains the details.
For SSMS 17 and later { ... }
and \1
wont work. Use ( ... )
and $1
instead.