I wish to refactor code using .NET regular expressions. The aim is to split declarations and assignments (for backwards compatibility with SQL 2005).
Sample Input:
DECLARE @clientCode char(10), @city nvarchar(100) = '', @country char(2) = 'US',
@clientId int
Desired Output:
DECLARE @clientCode char(10), @city nvarchar(100), @country char(2),
@clientId int
SELECT @city = '', @country = 'us'
This is what I have so far to match the input:
DECLARE\s+
(
,?
(@\w+\s+)
(\(.+\))?
(\=\s+\w+)?
)+
What replacement regex could I use to get the expected output?