fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var ColumnNames = new List<string> { "owner", "name", "owner-name"};
  12. ColumnNames = ColumnNames.OrderByDescending(x => x.Length).ToList();
  13. var s = "SELECT abc.name,abc.owner-name FROM XXX";
  14. var pattern = $@"\b(?:{string.Join("|", ColumnNames)})\b";
  15. Console.WriteLine(pattern);
  16. var result = Regex.Replace(s, pattern, "\"$&\"");
  17. Console.WriteLine(result);
  18. }
  19. }
Success #stdin #stdout 0.04s 21156KB
stdin
Standard input is empty
stdout
\b(?:owner-name|owner|name)\b
SELECT abc."name",abc."owner-name" FROM XXX