Ejemplo n.º 1
0
        public void TestReplacePattern()
        {
            var r = "test" +
                    Rp.GroupMatch("group1") +
                    Rp.ReplaceText("x") +
                    Rp.TheWholeInputText +
                    Rp.TheWholeMatch +
                    Rp.LastCapturedGroupMatch +
                    Rp.WholeTextBeforeTheMatch +
                    Rp.WholeTextAfterTheMatch +
                    Rp.GroupMatch(1) +
                    "abc_$".AsReplace();

            Assert.AreEqual(r.Expression, "test${group1}x$_$&$+$`$'$1abc_$$");

            var p = "eat" + Patterns.Symbols.WordEdge;
            var S = p.Replace("I eat meat", "hate", 1);

            Assert.AreEqual(S, "I hate meat");
        }
Ejemplo n.º 2
0
 public string Replace(string input, ReplacePattern replacement, RegexOptions options, TimeSpan matchTimeout)
 => Regex.Replace(input, this.Expression, replacement.Expression, options, matchTimeout);
Ejemplo n.º 3
0
 public string Replace(string input, ReplacePattern replacement)
 => Regex.Replace(input, this.Expression, replacement.Expression, RegexOptions.Multiline);
Ejemplo n.º 4
0
 public string Replace(string input, ReplacePattern replacement, RegexOptions options)
 => Regex.Replace(input, this.Expression, replacement.Expression, options);
Ejemplo n.º 5
0
 public string Replace(string input, ReplacePattern replacement, int count, RegexOptions options, TimeSpan matchTimeout)
 => new Regex(this.Expression, options, matchTimeout).Replace(input, replacement.Expression, count);
Ejemplo n.º 6
0
 public string Replace(string input, ReplacePattern replacement, int count, RegexOptions options)
 => new Regex(this.Expression, options).Replace(input, replacement.Expression, count);
Ejemplo n.º 7
0
 public string Replace(string input, ReplacePattern replacement, int count, int startAt)
 => new Regex(this.Expression, RegexOptions.Multiline).Replace(input, replacement.Expression, count, startAt);
Ejemplo n.º 8
0
 public static ReplacePattern AsReplace(this string text)
 => ReplacePattern.ReplaceText(text);