Esempio n. 1
0
        public static List <string> MatchRegexGroupsRecursive(BotData data, string input,
                                                              string pattern, string outputFormat, bool multiLine, string prefix = "", string suffix = "", bool urlEncodeOutput = false)
        {
            var parsed = RegexParser.MatchGroupsToString(input, pattern, outputFormat, multiLine ? RegexOptions.Multiline : RegexOptions.None)
                         .Select(p => prefix + p + suffix).Select(p => urlEncodeOutput ? Uri.UnescapeDataString(p) : p).ToList();

            data.Logger.LogHeader();
            data.Logger.Log($"Parsed {parsed.Count} values:", LogColors.Yellow);
            data.Logger.Log(parsed, LogColors.Yellow);
            return(parsed);
        }
Esempio n. 2
0
        public static List <string> MatchRegexGroupsRecursive(BotData data, string input,
                                                              string pattern, string outputFormat, string prefix = "", string suffix = "")
        {
            var parsed = RegexParser.MatchGroupsToString(input, pattern, outputFormat)
                         .Select(p => prefix + p + suffix).ToList();

            data.Logger.LogHeader();
            data.Logger.Log($"Parsed {parsed.Count} values:", LogColors.Yellow);
            data.Logger.Log(parsed, LogColors.Yellow);
            return(parsed);
        }
Esempio n. 3
0
        public static string MatchRegexGroups(BotData data, string input, string pattern, string outputFormat,
                                              string prefix = "", string suffix = "")
        {
            var parsed = RegexParser.MatchGroupsToString(input, pattern, outputFormat).FirstOrDefault() ?? string.Empty;

            parsed = prefix + parsed + suffix;

            data.Logger.LogHeader();
            data.Logger.Log($"Parsed value: {parsed}", LogColors.Yellow);
            return(parsed);
        }
Esempio n. 4
0
        private static List <string> ParseREGEX(string original, string pattern, string format, bool multiLine, bool caseSensitive)
        {
            var regexOptions = new RegexOptions();

            if (multiLine)
            {
                regexOptions |= RegexOptions.Singleline;
            }
            if (!caseSensitive)
            {
                regexOptions |= RegexOptions.IgnoreCase;
            }

            return(RegexParser.MatchGroupsToString(original, pattern, format, regexOptions).ToList());
        }
Esempio n. 5
0
        public static string MatchRegexGroups(BotData data, string input, string pattern, string outputFormat,
                                              bool multiLine, string prefix = "", string suffix = "", bool urlEncodeOutput = false)
        {
            var parsed = RegexParser.MatchGroupsToString(input, pattern, outputFormat, multiLine ? RegexOptions.Multiline : RegexOptions.None).FirstOrDefault() ?? string.Empty;

            parsed = prefix + parsed + suffix;

            if (urlEncodeOutput)
            {
                parsed = Uri.EscapeDataString(parsed);
            }

            data.Logger.LogHeader();
            data.Logger.Log($"Parsed value: {parsed}", LogColors.Yellow);
            return(parsed);
        }
Esempio n. 6
0
        public void MatchGroupsToString_NoMatches_MatchNothing()
        {
            var match = RegexParser.MatchGroupsToString(oneLineString, @"John went to the (.*)$", "[0]").FirstOrDefault();

            Assert.Null(match);
        }
Esempio n. 7
0
        public void MatchGroupsToString_SingleMatchEmptyOutputFormat_ReturnEmptyString()
        {
            var match = RegexParser.MatchGroupsToString(oneLineString, @"The ([^ ]*) is", string.Empty).FirstOrDefault();

            Assert.Equal(string.Empty, match);
        }
Esempio n. 8
0
        public void MatchGroupsToString_SingleMatch_GetGroups()
        {
            var match = RegexParser.MatchGroupsToString(oneLineString, @"The ([^ ]*) is on the (.*)$", "[1] - [2]").FirstOrDefault();

            Assert.Equal("cat - table", match);
        }
Esempio n. 9
0
        public void MatchGroupsToString_SingleMatch_GetFullMatch()
        {
            var match = RegexParser.MatchGroupsToString(oneLineString, @"The ([^ ]*) is", "[0]").FirstOrDefault();

            Assert.Equal("The cat is", match);
        }