mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 05:05:05 +00:00
feat: Added util methods for removing duplicate whitespace
This commit is contained in:
@@ -157,6 +157,21 @@ namespace ICD.Common.Utils.Extensions
|
|||||||
return new string(extends.Where(c => !char.IsWhiteSpace(c)).ToArray());
|
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>
|
/// <summary>
|
||||||
/// Removes all occurrences of the given string.
|
/// Removes all occurrences of the given string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -647,6 +647,16 @@ namespace ICD.Common.Utils
|
|||||||
return text == null ? null : text.RemoveWhitespace();
|
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>
|
/// <summary>
|
||||||
/// Returns true if the string is entirely whitespace characters, or empty, or null.
|
/// Returns true if the string is entirely whitespace characters, or empty, or null.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user