GCCHigh.Extensions.String
6.4.800
dotnet add package GCCHigh.Extensions.String --version 6.4.800
NuGet\Install-Package GCCHigh.Extensions.String -Version 6.4.800
<PackageReference Include="GCCHigh.Extensions.String" Version="6.4.800" />
paket add GCCHigh.Extensions.String --version 6.4.800
#r "nuget: GCCHigh.Extensions.String, 6.4.800"
// Install GCCHigh.Extensions.String as a Cake Addin #addin nuget:?package=GCCHigh.Extensions.String&version=6.4.800 // Install GCCHigh.Extensions.String as a Cake Tool #tool nuget:?package=GCCHigh.Extensions.String&version=6.4.800
Extensions.String contains methods to make logging to console, file, EventLog, SharePoint list, and database a breeze.
The following classes have been extended:
- System.String
with these methods:
BeginsWith()
Checks if the current string begins with the given target string.<br> For example:<br>
"GCCHigh.Extensions rock!".BeginsWith("GCCHigh")
<br> will return<br>true
<br> whereas<br>"GCCHigh.Extensions rock!".BeginsWith("gcchigh")
<br> will also return<br>true
<br> because the ignorecase switch defaults to true. Using the <br> ignorecase switch like this<br>"GCCHigh.Extensions rock!".BeginsWith("gcchigh", false)
<br> will return<br>false
<br> <br>ContainsAny()
Checks if the given string contains any of the characters or strings<br> provided in the IEnumerable.<br> This is useful for validating a given set of characters, like<br> special characters, or a given set of string, like bad words, is<br> not present in the target string.<br> <br>
ContainsOnly()
Checks if the given string contains only the characters or strings<br> provided in the IEnumerable.<br> This is useful for validating a string contains only hex chars etc.<br>
DoubleQuote()
Return the given string encased in double quotes. This is useful<br> when working with multi-layer quotes and strings where strings<br> contain quoted strings.<br>
EncodeAsXml()
Encode a given string as XML by encoding all ampersand, single <br> quote, greater than, less than and double quote characters into<br> their proper XML equivalent.<br>
ExceedsLength()
Checks if a referenced offset exceeds the length of the string.<br> Optionally increments the offset as well.<br> For example:<br>
"https://blog.cjvandyk.com Rocks!".ExceedsLength(30)
<br> will return False while<br>"https://blog.cjvandyk.com Rocks!".ExceedsLength(31, false)
<br> will also return False and<br>"https://blog.cjvandyk.com Rocks!".ExceedsLength(31)
<br> will return True.GetSiteUrl()
Given a full SharePoint Online object URL, this method will return<br> the site collection part of the URL.<br> For example:<br>
"https://crayveon.sharepoint.com/sites/TheSite/lists/TheList".GetTenantUrl()
<br> would returnhttps://crayveon.sharepoint.com/sites/TheSite
GetTenantUrl()
Given a full SharePoint Online object URL, this method will return<br> only the tenant part of the URL.<br> For example:<br>
"https://crayveon.sharepoint.com/sites/TheSite/lists/TheList".GetTenantUrl()
<br> would returnhttps://crayveon.sharepoint.com
GetUrlRoot()
Get the URL root for the given string object containing a URL.<br> For example:<br>
"https://blog.cjvandyk.com".GetUrlRoot()
<br> will return "https://blog.cjvandyk.com" whereas<br>"https://blog.cjvandyk.com/sites/Approval".GetUrlRoot()
<br> will also return "https://blog.cjvandyk.com".HasLower()
Validates that the given string object contains a lower case character.<br> For example:<br>
"abc".HasLower()
<br> will return True whereas<br>"ABC".HasLower()
<br> will return False and<br>"AbC".HasLower()
<br> will return True.HasNumeric()
Validates that the given string object contains a number character.<br> For example:<br>
"abc".HasNumeric()
<br> will return False whereas<br>"ABC123".HasNumeric()
<br> will return True and<br>"A2C".HasNumeric()
<br> will return True.HasSymbol()
Validates that the given string object contains a symbol or special<br> character.<br> For example:<br>
"abc".HasSymbol()
<br> will return False whereas<br>"ABC$".HasSymbol()
<br> will return True and<br>"A@C".HasSymbol()
<br> will return True.HasUpper()
Validates that the given string object contains a lower case character.<br> For example:<br>
"abc".HasUpper()
<br> will return False whereas<br>"ABC".HasUpper()
<br> will return True and<br>"AbC".HasUpper()
<br> will return True.HtmlDecode()
Decode the HTML escaped components in a given string returning the<br> given source string without HTML escaped components.<br> For example:<br>
"https://blog.cjvandyk.com/sites/Rocks <&> Rolls!".HtmlDecode()
<br> will return<br>https://blog.cjvandyk.com/sites/Rocks <&> Rolls!
HtmlEncode()
Encode the given string to be HTML safe.<br> For example:<br>
"https://blog.cjvandyk.com/sites/Rocks <&> Rolls!".HtmlEncode()
<br> will return<br>https://blog.cjvandyk.com/sites/Rocks <&> Rolls!
IsAlpha()
Validates that the given string object contains all alphabetic<br> characters (a-z and A-Z) returning True if it does and False if<br> it doesn't.<br> For example:<br>
"abcXYZ".IsAlphabetic()
<br> will return True whereas<br>"abc123".IsAlphabetic()
<br> will return False.IsAlphaNumeric()
Validates that the given string object contains all alphabetic<br> and/or numeric characters (a-z and A-Z and 0-9) returning True if it<br> does and False if it doesn't.<br> For example:<br>
"abc123".IsAlphaNumeric()
<br> will return True whereas<br>"abcxyz".IsAlphaNumeric()
<br> will also return True and<br>"123456".IsAlphaNumeric()
<br> will also return True but<br>"abc!@#".IsAlphaNumeric()
<br> will return False.IsChar()
This method takes a char[] as one of its arguments against which the<br> given string object is validated. If the given string object contains<br> only characters found in the char[] it will return True, otherwise it<br> will return False.<br> For example:<br>
"aacc".IsChar(new char[] {'a', 'c'})
<br> will return True whereas<br>"abc123".IsChar(new char[] {'a', 'c'})
<br> will return False.IsDateTime()
Validates that the given string is a valid date/time given the format.<br> It provides an easy way to validate date string input.<br> For example these:<br>
"20170704033333".IsDateTime("yyyMMddHHmmss")
<br>"07/27/2017 03:33:33".IsDateTime("MM/dd/yyyy HH:mm:ss")
<br>"27/07/2017 03:33:33".IsDateTime("dd/MM/yyyy HH:mm:ss")
<br>"27/07/2017".IsDateTime("dd/MM/yyyy")
<br> will all return True whereas these:<br>"2017070403333".IsDateTime("yyyMMddHHmmss")
<br> 2017/07/04 03:33:3 is clearly missing another digit.<br>"07/27/2017".IsDateTime("dd/MM/yyyy HH:mm:ss")
<br> 07/27 fails because there isn't 27 months.<br>"27/07/2017".IsDateTime("MM/dd/yyyy")
<br> 27/07 fails for the same reason.<br> will return False.IsEmail()
Validates that the given string object contains a valid email address.<br> For example:<br>
"noreply@crayveon.com".IsEmail()
<br> will return True whereas<br>"noreplay-at-crayveon.com".IsEmail()
<br> will return False.IsHex()
Checks if the given string represents hex based numbers.<br> For example:<br>
"9723FDC".IsHex()
<br> will return True whereas<br>"9723FDT.IsHex()
<br> will return False because T is not a hex character.IsLower()
Validates that the given string object contains only lower case letters.<br> For example:<br>
"IsLower test".IsLower()
<br> will return False while<br>"islower test".IsLower()
<br> will return True and<br>"islower test".IsLower(false)
<br> will return False.IsNumeric()
Validates that the given string object contains all numeric<br> characters (0-9) returning True if it does and False if it<br> doesn't.<br> For example:<br>
"123456".IsNumeric()
<br> will return True whereas<br>"abc123".IsNumeric()
<br> will return False.IsStrong()
Validates that the given string object contains a strong password string.<br> For example:<br>
"abc123XYZ!@#".IsStrong()
<br> will return True whereas<br>"abc123XYZ".IsStrong()
<br> will return False and<br>"abc123XYZ".IsStrong(3)
<br> will return True and<br>"abc123XYZ".IsStrong(2)
<br> will return True.<br> The number parameter for IsStrong() indicates the number of criteria<br> that has to be true before the string is considered strong. Valid<br> values are 1 through 4 with the default value being 4.IsUpper()
Validates that the given string object contains only upper case letters.<br> For example:<br>
"IsUpper test".IsUpper()
<br> will return False while<br>"ISUPPER TEST".IsUpper()
<br> will return True and<br>"ISUPPER TEST".IsUpper(false)
<br> will return False.IsUrlRoot()
Check if the given string object containing a URL, is that of the<br> URL root only. Returns True if so, False if not.<br> For example:<br>
"https://blog.cjvandyk.com".IsUrlRootOnly()
<br> will return True whereas<br>"https://blog.cjvandyk.com/sites/Approval".IsUrlRootOnly()
<br> will return False.IsVowel()
Checks if the given char/string is an English vowel.<br> This allows the developer the ability to check a string without<br> having to first convert to a char e.g. as a substring return.<br> For example:<br>
"test".Substring(2, 1).IsVowel()
<br> will return False since the "s" is checked whereas<br>"test".Substring(1, 1).IsVowel()
<br> will return True since the "e" is checked.IsZip()
Checks if the given string object is in the valid format<br> of a United States zip code i.e. nnnnn-nnnn or just nnnnn.<br> For example:<br>
"12345-6789".IsZipCode()
<br> will return True whereas<br>"1234-56789".IsZipCode()
<br> will return False.<br>"12345".IsZipCode()
<br> will return True.<br>
"123456".IsZipCode()
<br> will return False.<br>"1234".IsZipCode()
<br> will return False.Left()
This method returns text to the left of the index string. Use negative values for occurrence if the occurrence count should start from the end instead of its default from the beginning of the string.
Lines()
This method returns the number of lines/sentences in the given string<br> object.
LoremIpsum()
Poplates the given string with a given number of paragraphs of dummy<br> text in the lorem ipsum style. For example:<br>
"".LoremIpsum(2)
<br> would yield<br> "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer<br> aliquam arcu rhoncus erat consectetur, quis rutrum augue tincidunt.<br> Suspendisse elit ipsum, lobortis lobortis tellus eu, vulputate<br> fringilla lorem. Cras molestie nibh sed turpis dapibus sollicitudin<br> ut a nulla. Suspendisse blandit suscipit egestas. Nunc et ante mattis<br> nulla vehicula rhoncus. Vivamus commodo nunc id ultricies accumsan.<br> Mauris vitae ante ut justo venenatis tempus.<br> <br> Nunc posuere, nisi eu convallis convallis, quam urna sagittis ipsum,<br> et tempor ante libero ac ex. Aenean lacus mi, blandit non eros luctus,<br> ultrices consectetur nunc. Vivamus suscipit justo odio, a porta massa<br> posuere ac. Aenean varius leo non ipsum porttitor eleifend. Phasellus<br> accumsan ultrices massa et finibus. Nunc vestibulum augue ut bibendum<br> facilisis. Donec est massa, lobortis quis molestie at, placerat a<br> neque. Donec quis bibendum leo. Pellentesque ultricies ac odio id<br> pharetra. Nulla enim massa, lacinia nec nunc nec, egestas pulvinar<br> odio. Sed pulvinar molestie justo, eu hendrerit nunc blandit eu.<br> Suspendisse et sapien quis ipsum scelerisque rutrum."<br>Match()
Checks if the current string matches a given search mask.<br> It ignores duplicate '' in the mask. '' is matched against<br> 0 or more characters. Duplicate '?' is treated as requiring<br> the number of characters. '?' is matched against 1 or more<br> characters.<br> For example:<br>
"abcdefgh".Match("***a?c*")
<br> will return True while<br>"abcdefgh".Match("***ac*")
<br> will return False but<br>"abcdefgh".Match("?a?c*")
<br> will also return False because the first '?' requires a character<br> before 'a'.MorseCodeBeep()
Takes a given System.String representing Morse code and audiblize<br> it according to standards.<br> https://www.infoplease.com/encyclopedia/science/engineering/electrical/morse-code<br> Assumes the input value to be in Morse code format already.<br> Use
.ToMorseCode()
to pre-convert text if needed.QueryStringToDictionary()
Converts the current string (QueryString) to a dictionary of string<br> objects for example:<br>
"?id=123&url=blog.cjvandyk.com&rating=awesome".QueryStringToDictionary()
<br> will return a dictionary with 3 entries thus:<br>["id"] = "123"
<br>["url"] = "blog.cjvandyk.com"
<br>["rating"] = "awesome"
<br>QueryStringToNameValueCollection()
Converts the current string (QueryString) to a NameValueCollection<br> a List of KeyValue pairs. The main difference from
.QueryStringToDictionary()
<br> is that duplicates can be contained in the list for example:<br>"?id=123&url=blog.cjvandyk.com&id=789".QueryStringToNameValueCollection()
<br> will return a dictionary with 3 entries thus:<br>["id"] = "123"
<br>["url"] = "blog.cjvandyk.com"
<br>["id"] = "789"
<br>Quote()
RemoveExtraSpace()
ReplaceTokens()
Right()
SingleQuote()
Singularize()
SubString()
TailString()
ToBinary()
ToEnglishAlphaChars()
ToEnum()
ToJson()
ToMorseCode()
TrimLength()
TrimStart()
Validate()
ValidateNoNulls()
Words()
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 is compatible. net471 is compatible. net472 is compatible. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- GCCHigh.Extensions.Constants (>= 6.4.800)
-
.NETFramework 4.7
- GCCHigh.Extensions.Constants (>= 6.4.800)
-
.NETFramework 4.7.1
- GCCHigh.Extensions.Constants (>= 6.4.800)
-
.NETFramework 4.7.2
- GCCHigh.Extensions.Constants (>= 6.4.800)
-
.NETFramework 4.8
- GCCHigh.Extensions.Constants (>= 6.4.800)
-
.NETStandard 2.0
- GCCHigh.Extensions.Constants (>= 6.4.800)
-
.NETStandard 2.1
- GCCHigh.Extensions.Constants (>= 6.4.800)
-
net6.0
- GCCHigh.Extensions.Constants (>= 6.4.800)
-
net7.0
- GCCHigh.Extensions.Constants (>= 6.4.800)
-
net8.0
- GCCHigh.Extensions.Constants (>= 6.4.800)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on GCCHigh.Extensions.String:
Package | Downloads |
---|---|
GCCHigh.Extensions.Identity
GCCHigh.Extensions.Identity contains modern OAuth2 extension methods for C# specifically targeted to the GCCHigh M365 environment. GCCHigh.Extensions supports all versions of.NET from 4.6.2 through 8.0. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Rebranded Extensions.String as GCCHigh.Extensions.String.