/// <summary> /// Replaces all occurrences of the previously defined pattern with the /// <paramref name="replacement"/> pattern, starting at the character position /// <paramref name="startat"/>. /// </summary> public string Replace(string input, string replacement, int count, int startat) { if (input == null) throw new ArgumentNullException(nameof(input)); if (replacement == null) throw new ArgumentNullException(nameof(replacement)); // a little code to grab a cached parsed replacement object RegexReplacement repl = (RegexReplacement)_replref.Get(); if (repl == null || !repl.Pattern.Equals(replacement)) { repl = RegexParser.ParseReplacement(replacement, caps, capsize, capnames, roptions); _replref.Cache(repl); } return repl.Replace(this, input, count, startat); }
// Does the replacement //| <include file='doc\Regex.uex' path='docs/doc[@for="Regex.Replace4"]/*' /> /// <devdoc> /// <para> /// Replaces all occurrences of the <paramref name="pattern "/>with the recent /// <paramref name="replacement"/> pattern, starting at the character position /// <paramref name="startat."/> /// </para> /// </devdoc> public String Replace(String input, String replacement, int count, int startat) { RegexReplacement repl; if (input == null) { throw new ArgumentNullException("input"); } if (replacement == null) { throw new ArgumentNullException("replacement"); } // a little code to grab a cached parsed replacement object repl = (RegexReplacement)replref.Get(); if (repl == null || !repl.Pattern.Equals(replacement)) { repl = RegexParser.ParseReplacement(replacement, caps, capsize, capnames, this.roptions); replref.Cache(repl); } return(repl.Replace(this, input, count, startat)); }