using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(theColumnName)[\s\S]*?[\d]+";
string input = @" Line 62: DECLARE @pStrtheColumnName VARCHAR(10)
Line 198: theColumnName VARCHAR(10),
Line 282: INSERT INTO #Temp(theColumnName
Line 297: SELECT P.SomeCol, P.theColumnName, P.OtherColumn, P.AnotherCol,
Line 385: SELECT SomeCol, theColumnName, AnotherCol, ThirdCol,
Line 400: ORDER BY Col1, Col2, theColumnName
Line 404: FETCH NEXT FROM curCMS INTO @pStrCode, @pStrtheColumnName, @pSomeDate,
Line 436: SET @pStrProcessLine = @pStrProcessLine + ISNULL(SUBSTRING(@pStrtheColumnName,1,10), '') + @pStrDelimiter
Line 555: FETCH NEXT FROM myCursor INTO @pStrCode, @pStrtheColumnName, @pSomeDate,
Line 597: ORDER BY E.SomeDate, E.AnotherDate, E.theColumnName
Line 654: + 'ORDER BY AdmissionDate, DischargeDate, theColumnName' + @Cr";
foreach (Match m in Regex.Matches(input, pattern))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx