using System; using System.Collections.Generic; using System.Text.RegularExpressions; public class Test { public static void Main() { var str = @"CREATE TABLE [dbo].[Event]( [ID] [int] IDENTITY(1,1) NOT NULL, [Date Started] [datetime] NOT NULL, [StartTime] [time](7) NOT NULL, [Description] [nvarchar](250) NULL, [AudioLocation] [nvarchar](max) NOT NULL, [PlayerLocation] [nvarchar](max) NOT NULL, CONSTRAINT [PK_dbo.Event] PRIMARY KEY CLUSTERED"; var result = Regex.Replace(str, @"\[(\w+)]|\[([^]]+)]", m => m.Groups[1].Success ? m.Groups[1].Value : $"\"{m.Groups[2].Value}\""); Console.WriteLine(result); } }