25 lines
717 B
C#
25 lines
717 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace RhinoReminds.Utilities
|
|
{
|
|
public static class TextHelpers
|
|
{
|
|
public static string ReplaceMultiple(this string input, IEnumerable<string> regexes, IEnumerable<string> replacements, RegexOptions options = RegexOptions.None)
|
|
{
|
|
using (IEnumerator<string> regexIterator = regexes.GetEnumerator())
|
|
using (IEnumerator<string> replacementsIterator = replacements.GetEnumerator()) {
|
|
while (regexIterator.MoveNext() && replacementsIterator.MoveNext()) {
|
|
input = Regex.Replace(
|
|
input,
|
|
regexIterator.Current, replacementsIterator.Current,
|
|
options
|
|
);
|
|
}
|
|
}
|
|
return input;
|
|
}
|
|
}
|
|
}
|