using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(/[^:"" ()]+\..[^: ""()]+):-?(\d.*?):(\d.*)?.*?((?:warning|error|note): (?:(?![\r\n]{2})[\s\S])+)";
string input = @"Build failed: Command failed with exit code 1.
stderr: /sample/path/to/SampleFile.java:1: error: [PackageLocation] Expected package /sample/path/to/ to be declared in a directory ending with /sample/path/to, instead found /sample/path/To
package sample.path.to;
(see http://errorprone.info/bugpattern/PackageLocation)
/sample/path/to/SampleFile2.java:-1: note: Some input files use or override a deprecated API.
/sample/path/to/SampleFile2.java:-1:6 note: Recompile with -Xlint:deprecation for details.";
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