Exemple #1
0
        public static IEnumerable MatchesAt(SqlRegex regex, [SqlFacet(MaxSize = -1)] SqlString input, [DefaultValue("NULL")] SqlInt32 startat)
        {
            if (regex == null)
            {
                throw new ArgumentNullException("regex");
            }

            if (regex.IsNull || input.IsNull)
            {
                yield break;
            }

            MatchCollection matches = regex.Regex.Matches(input.Value, !startat.IsNull ? startat.Value : 0);

            for (int i = 0; i < matches.Count; i++)
            {
                Match match = matches[i];
                for (int j = 0; j < match.Groups.Count; j++)
                {
                    Group group = match.Groups[j];
                    if (!group.Success)
                    {
                        yield return(new MatchRow(i, j, -1, group.Success, regex.Regex.GroupNameFromNumber(j), group.Index, group.Length, group.Value));
                    }
                    else
                    {
                        for (int k = 0; k < group.Captures.Count; k++)
                        {
                            Capture capture = group.Captures[k];
                            yield return(new MatchRow(i, j, k, group.Success, regex.Regex.GroupNameFromNumber(j), capture.Index, capture.Length, capture.Value));
                        }
                    }
                }
            }
        }
Exemple #2
0
        public static IEnumerable SplitLimAt(SqlRegex regex, [SqlFacet(MaxSize = -1)] SqlString input, [DefaultValue("NULL")] SqlInt32 count, [DefaultValue("NULL")] SqlInt32 startat)
        {
            if (regex == null)
            {
                throw new ArgumentNullException("regex");
            }

            if (regex.IsNull || input.IsNull)
            {
                yield break;
            }

            var results = regex.Regex.Split(input.Value, !count.IsNull ? count.Value : int.MaxValue, !startat.IsNull ? startat.Value : 0);

            for (int i = 0; i < results.Length; i++)
            {
                yield return(results[i]);
            }
        }
Exemple #3
0
        public static IEnumerable Split(SqlRegex regex, [SqlFacet(MaxSize = -1)] SqlString input)
        {
            if (regex == null)
            {
                throw new ArgumentNullException("regex");
            }

            if (regex.IsNull || input.IsNull)
            {
                yield break;
            }

            var results = regex.Regex.Split(input.Value);

            for (int i = 0; i < results.Length; i++)
            {
                yield return(results[i]);
            }
        }