35
1
using System;
2
using System.Text.RegularExpressions;
3
4
namespace HelloWorld
5
{
6
public class Program
7
{
8
public static void Main(string[] args)
9
{
10
try
11
{
12
string regexPattern = @"\hel#lo\m";
13
Regex regex = new Regex(regexPattern);
14
string inputString = "hello world!";
15
Match match = regex.Match(inputString);
16
if (match.Success)
17
{
18
Console.WriteLine("Match found.");
19
}
20
else
21
{
22
Console.WriteLine("No match found.");
23
}
24
}
25
catch (RegexMatchTimeoutException ex)
26
{
27
Console.WriteLine("Timeout Error: " + ex.Message);
28
}
29
catch (RegexParseException ex)
30
{
31
Console.WriteLine("Error in parsing regular expression: " + ex.Message);
32
}
33
}
34
}
35
}
Cached Result