using System.Text.RegularExpressions;
public static void Main()
string sql = "SELECT TOP 150 * FROM tbl WHERE XYZ = 123";
if ("maria".Equals(config)) {
Regex regex = new Regex(@"(SELECT.*?)TOP (\d+)(.*)");
string output = regex.Replace(sql, "$1 $3 LIMIT $2");
Console.WriteLine(output);