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

text string
The string to process.
charsToReplace ReadOnlySpan<char>
The characters to replace.
replacement char
The character to replace the old characters with.
skipConsecutiveReplacements bool 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 text is null.