This commit is contained in:
2020-11-26 16:13:00 +01:00
parent 0696694919
commit f697330b12
13 changed files with 370 additions and 218 deletions
+17
View File
@@ -1,11 +1,28 @@
using System;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
namespace zero.Core.Extensions
{
public static class StringExtensions
{
const string SPACE = " ";
static Regex replaceMultipleSpacesRegex { get; } = new Regex("[ ]{2,}", RegexOptions.None);
public static string FullTrim(this string value)
{
if (String.IsNullOrEmpty(value))
{
return value;
}
return replaceMultipleSpacesRegex.Replace(value, SPACE).Trim();
}
public static string EnsureStartsWith(this string input, string toStartWith)
{
if (input.StartsWith(toStartWith)) return input;