///////////////////////////////////////////////////////////////////////////// public static string AssureNoLeadingDot( this string str ) { var strOut = str?.Trim() ?? string.Empty; while( !string.IsNullOrEmpty( strOut ) && '.' == strOut.First() ) { strOut = strOut.Substring( 1 ); } return strOut; }
public static bool IsNullOrWhiteSpace(this string self) { #if NET35 return string.IsNullOrEmpty(self?.Trim()); #else return string.IsNullOrWhiteSpace(self); #endif }
///////////////////////////////////////////////////////////////////////////// public static string AssureLeadingDot( this string str, bool addForEmptyStr = false ) { var strOut = str?.Trim() ?? string.Empty; if( string.IsNullOrEmpty(strOut) && addForEmptyStr ) { return "."; } if( !string.IsNullOrEmpty(strOut) && '.' != strOut.First() ) { strOut = "." + strOut; } return strOut; }
static public DroneLabel AsDroneLabel(this string DroneLabel) { var Name = DroneLabel?.Trim(); string Status = null; var Match = DroneEntryLabelRegex.Match(DroneLabel ?? ""); if (Match.Success) { Name = Match.Groups[1].Value?.Trim(); Status = Match.Groups[2].Value?.RemoveXmlTag()?.Trim(); } return new DroneLabel() { Name = Name, Status = Status, }; }
public static string TrimSafe(this string s, params char[] chars) => s?.Trim(chars);
public static string SafeTrim(this string cad,params char[] trimChars) => cad?.Trim(trimChars);
public static string SafeTrim(this string cad)=>cad?.Trim();
/// <summary> /// Safely trim leading and trailing whitespace from the string, returning <c>null</c> if it is <c>null</c>. /// </summary> /// <param name="toTrim"> /// The string to trim. /// </param> /// <returns> /// The trimmed string, or <c>null</c> if <paramref name="toTrim"/> is <c>null</c>. /// </returns> public static string SafeTrim(this string toTrim) { return toTrim?.Trim(); }
public static bool IsNumericString(this string str) { return str?.Trim().All(Char.IsDigit) == true; }
/// <summary> /// Shortcut to string.Trim(text, trimChars) /// <para>Return string.Empty if input string is null</para> /// </summary> public static string TrimOrEmpty(this string text, params char[] trimChars) { return text?.Trim(trimChars) ?? string.Empty; }
/// <summary> /// Shortcut to string.Trim(text) /// <para>Return string.Empty if input string is null</para> /// </summary> public static string TrimOrEmpty(this string text) { return text?.Trim() ?? string.Empty; }
// ReSharper disable once InconsistentNaming public static string trim(this string source) { source = source?.Trim(); return source; }
public static bool IsNullOrWhiteSpace(this string value) { return string.IsNullOrEmpty(value?.Trim()); }