string str = @"SELECT OrderTable.HJSL, Company.CompanyName FROM OrderTable INNER JOIN Company ON OrderTable.CompanyID = Company.CompanyID WHERE (OrderTable.CompanyID > 1000)"; Regex re = new Regex("SELECT\\s+(.*?)FROM\\s+(.*?)WHERE\\s+(.*?)", RegexOptions.None); MatchCollection mc = re.Matches(str.Replace("\r\n","")); foreach (Match ma in mc) { Console.WriteLine(ma.Groups[1].Value); Console.WriteLine(ma.Groups[2].Value); Console.WriteLine(ma.Groups[3].Value); } Console.ReadLine();
string select=m.Groups["select"].Value;
......
(?is)(?<=select).*(?=from)|(?<=from).*(?=where)|(?<=where).*
错误是“Not Enough.”
string str = @"SELECT OrderTable.HJSL, Company.CompanyName
FROM OrderTable INNER JOIN
Company ON OrderTable.CompanyID = Company.CompanyID
WHERE (OrderTable.CompanyID > 1000)"; Regex re = new Regex("SELECT\\s+(.*?)FROM\\s+(.*?)WHERE\\s+(.*?)", RegexOptions.None);
MatchCollection mc = re.Matches(str.Replace("\r\n",""));
foreach (Match ma in mc)
{
Console.WriteLine(ma.Groups[1].Value);
Console.WriteLine(ma.Groups[2].Value);
Console.WriteLine(ma.Groups[3].Value);
} Console.ReadLine();