using System.Collections.Generic;
using System.Text.RegularExpressions;
public static readonly Regex regex = new Regex(@"(:+)(\S+)", RegexOptions.Compiled | RegexOptions.Multiline);
public static void Main(string[] args)
Console.WriteLine("Resultado 1:");
ExtrairParametros("SELECT * FROM TABELA WHERE CAMPO1 = :PARAM1 AND CAMPO2 = AND CAMPO2 = :PARAM2").ForEach(Console.WriteLine);
Console.WriteLine("Resultado 2:");
ExtrairParametros("SELECT * FROM TABELA WHERE CAMPO1 = : AND CAMPO2 = :PARAM2").ForEach(Console.WriteLine);
public static List<string> ExtrairParametros(string query)
List<string> parametros = new List<string>();
if (regex.IsMatch(query))
foreach (Match match in regex.Matches(query))
parametros.Add(match.Value);