feat: Initial commit of RegexUtils

This commit is contained in:
Chris Cameron
2018-08-31 09:52:53 -04:00
parent 0c35e3225c
commit ed299b8d4f
2 changed files with 35 additions and 0 deletions

View File

@@ -116,6 +116,7 @@
<Compile Include="Properties\Annotations.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RecursionUtils.cs" />
<Compile Include="RegexUtils.cs" />
<Compile Include="ReprBuilder.cs" />
<Compile Include="Services\Scheduler\AbstractScheduledAction.cs" />
<Compile Include="Services\Scheduler\ActionSchedulerService.cs" />

View File

@@ -0,0 +1,34 @@
using System.Text.RegularExpressions;
namespace ICD.Common.Utils
{
public static class RegexUtils
{
/// <summary>
/// Shim to perform Match and Matches in one call.
/// </summary>
/// <param name="input"></param>
/// <param name="pattern"></param>
/// <param name="match"></param>
/// <returns></returns>
public static bool Matches(string input, string pattern, out Match match)
{
match = Regex.Match(input, pattern);
return match.Success;
}
/// <summary>
/// Shim to perform Match and Matches in one call.
/// </summary>
/// <param name="input"></param>
/// <param name="pattern"></param>
/// <param name="options"></param>
/// <param name="match"></param>
/// <returns></returns>
public static bool Matches(string input, string pattern, RegexOptions options, out Match match)
{
match = Regex.Match(input, pattern, options);
return match.Success;
}
}
}