From a372d978689957f09af72bee83bdbb1f063427fc Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Wed, 19 Dec 2018 07:50:23 -0500 Subject: [PATCH] feat: Adding RegexUtils shims for RegexOptions --- ICD.Common.Utils/RegexUtils.cs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/ICD.Common.Utils/RegexUtils.cs b/ICD.Common.Utils/RegexUtils.cs index 727de4d..0db86a2 100644 --- a/ICD.Common.Utils/RegexUtils.cs +++ b/ICD.Common.Utils/RegexUtils.cs @@ -44,7 +44,7 @@ namespace ICD.Common.Utils /// public static string ReplaceGroup(string input, string pattern, string groupName, string replacement) { - return ReplaceGroup(input, pattern, groupName, match => replacement); + return ReplaceGroup(input, pattern, groupName, replacement, RegexOptions.None); } /// @@ -56,6 +56,34 @@ namespace ICD.Common.Utils /// /// public static string ReplaceGroup(string input, string pattern, string groupName, Func replacement) + { + return ReplaceGroup(input, pattern, groupName, replacement, RegexOptions.None); + } + + /// + /// Uses the pattern to replace the specified group with the provided replacement string. + /// + /// + /// + /// + /// + /// + /// + public static string ReplaceGroup(string input, string pattern, string groupName, string replacement, RegexOptions options) + { + return ReplaceGroup(input, pattern, groupName, match => replacement, options); + } + + /// + /// Uses the pattern to replace the specified group with the provided replacement string. + /// + /// + /// + /// + /// + /// + /// + public static string ReplaceGroup(string input, string pattern, string groupName, Func replacement, RegexOptions options) { MatchEvaluator evaluator = m => @@ -81,7 +109,7 @@ namespace ICD.Common.Utils return sb.ToString(); }; - return Regex.Replace(input, pattern, evaluator); + return Regex.Replace(input, pattern, evaluator, options); } } }