CSharp · Console
using System;
using System.Text.RegularExpressions;
public class Program
{
public static void Main()
{
var text = "fakeLogOpen(/dev/log_crash) failed";
var androidErrorRegex = new Regex (@"
^
( # start optional path followed by `:`
(?<path>
(?<file>.+[\\/][^:\(]+)
(
([:](?<line>\d+))
|
(\((?<line>\d+)\))
)?
)
\s*
:
)?
( # optional warning|error:
\s*
(?<level>(warning|error)[^:]*)\s*
:
)?
\s*
(?<message>.*)
$
", RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace);
Console.WriteLine("IsMatch: " + androidErrorRegex.IsMatch(text));
}
}