mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
feat: Added util methods for removing duplicate whitespace
This commit is contained in:
parent
28f4818ca3
commit
bf8c320d66
2 changed files with 25 additions and 0 deletions
|
|
@ -157,6 +157,21 @@ namespace ICD.Common.Utils.Extensions
|
|||
return new string(extends.Where(c => !char.IsWhiteSpace(c)).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces spans of whitespace with a single space.
|
||||
/// </summary>
|
||||
/// <param name="extends"></param>
|
||||
/// <returns></returns>
|
||||
[PublicAPI]
|
||||
[NotNull]
|
||||
public static string RemoveDuplicateWhitespace([NotNull] this string extends)
|
||||
{
|
||||
if (extends == null)
|
||||
throw new ArgumentNullException("extends");
|
||||
|
||||
return Regex.Replace(extends, @"\s+", " ");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all occurrences of the given string.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -647,6 +647,16 @@ namespace ICD.Common.Utils
|
|||
return text == null ? null : text.RemoveWhitespace();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces spans of whitespace with a single space.
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
public static string RemoveDuplicateWhitespace(string text)
|
||||
{
|
||||
return text == null ? null : text.RemoveDuplicateWhitespace();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the string is entirely whitespace characters, or empty, or null.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue