StringManipulation.ReplaceChars Method
- Namespace
- Kampute.DocToolkit.Support
- Assembly
- Kampute.DocToolkit.dll
Definition
Replaces multiple characters in the given string with a single character.
public static string ReplaceChars(this
string text,
ReadOnlySpan<char> charsToReplace,
char replacement,
bool skipConsecutiveReplacements = false)Parameters
textstring- The string to process.
charsToReplaceReadOnlySpan<char>- The characters to replace.
replacementchar- The character to replace the old characters with.
skipConsecutiveReplacementsbool optional- Indicates whether to skip consecutive occurrences of the replacement character.
Returns
- string
- A new string with the specified characters replaced.
Exceptions
- ArgumentNullException
- Thrown when
textisnull.
