Refactored previous PR

This commit is contained in:
ruri
2020-03-23 04:21:19 +01:00
parent 341edb3aef
commit ca79ffe9cd
2 changed files with 8 additions and 9 deletions
+6 -1
View File
@@ -309,7 +309,12 @@ namespace RuriLib
throw new NotImplementedException("XPATH parsing is not implemented yet");
case ParseType.REGEX:
list = Parse.REGEX(original, ReplaceValues(regexString, data), ReplaceValues(regexOutput, data), recursive, dotMatches, caseSensitive).ToList();
RegexOptions regexOptions = new RegexOptions();
if (dotMatches)
regexOptions |= RegexOptions.Singleline;
if (caseSensitive == false)
regexOptions |= RegexOptions.IgnoreCase;
list = Parse.REGEX(original, ReplaceValues(regexString, data), ReplaceValues(regexOutput, data), regexOptions, recursive).ToList();
break;
}
+2 -8
View File
@@ -241,17 +241,11 @@ namespace RuriLib.Utils.Parsing
/// <param name="pattern">The Regex pattern containing groups</param>
/// <param name="output">The output format string, for which [0] will be replaced with the full match, [1] with the first group etc.</param>
/// <param name="recursive">Whether to make multiple matches</param>
/// <param name="dotMatches">Whether Regex . matches over multiple lines</param>
/// <param name="caseSensitive">Whether Regex is case sensitive</param>
/// <param name="options">The Regex Options to use</param>
/// <returns>The parsed string(s).</returns>
public static IEnumerable<string> REGEX(string input, string pattern, string output, bool recursive = false, bool dotMatches = false, bool caseSensitive = true)
public static IEnumerable<string> REGEX(string input, string pattern, string output, RegexOptions options, bool recursive = false)
{
var list = new List<string>();
RegexOptions options = new RegexOptions();
if (dotMatches)
options |= RegexOptions.Singleline;
if (caseSensitive == false)
options |= RegexOptions.IgnoreCase;
if (recursive)
{