Exemplo n.º 1
0
        public override string GetRegexPattern()
        {
            if (String.IsNullOrEmpty(EscapesWith))
            {
                if (EndsWith.CompareTo(@"\n") == 0)
                {
                    return(String.Format(@"{0}[^\n\r]*", Escape(BeginsWith)));
                }

                return(String.Format(@"{0}[\w\W\s\S]*?{1}", Escape(BeginsWith), Escape(EndsWith)));
            }

            return(String.Format("{0}(?>{1}.|[^{2}]|.)*?{3}", new object[] { Regex.Escape(BeginsWith), Regex.Escape(EscapesWith.Substring(0, 1)), Regex.Escape(EndsWith.Substring(0, 1)), Regex.Escape(EndsWith) }));
        }
Exemplo n.º 2
0
 public override string GetRegexPattern()
 => string.IsNullOrEmpty(EscapesWith)
     ? string.Equals(EndsWith, @"\n", StringComparison.Ordinal) ? $@"{Escape(BeginsWith)}[^\n\r]*" : $@"{Escape(BeginsWith)}[\w\W\s\S]*?{Escape(EndsWith)}"
     : $"{Regex.Escape(BeginsWith)}(?>{Regex.Escape(EscapesWith.Substring(0, 1))}.|[^{Regex.Escape(EndsWith.Substring(0, 1))}]|.)*?{Regex.Escape(EndsWith)}";