RegExpose.RegexEngine.Replace C# (CSharp) Méthode

Replace() public méthode

public Replace ( string>.Func matchEvaluator, int count = int.MaxValue ) : string
matchEvaluator string>.Func
count int
Résultat string
        public string Replace(Func<Match, string> matchEvaluator, int count = int.MaxValue)
        {
            var inputReplacement = new StringBuilder(_input);

            var replacementLengthDifference = 0;
            // We need to account for the possibility that a replacement might have a different length than its match.
            var match = GetMatch();
            for (var i = 0; i < count && match != null; i++, match = match.NextMatch())
            {
                var replacement = matchEvaluator(match);
                inputReplacement.Remove(match.Index + replacementLengthDifference, match.Length);
                inputReplacement.Insert(match.Index + replacementLengthDifference, replacement);

                replacementLengthDifference += replacement.Length - match.Length;
            }

            return inputReplacement.ToString();
        }

Same methods

RegexEngine::Replace ( string replacement ) : string
RegexEngine::Replace ( string replacement, int count ) : string