StringExtensions Class

Contains custom extension methods to use with a String type.

Definition

Namespace: DevCase.Extensions.StringExtensions
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[HideModuleNameAttribute]
public sealed class StringExtensions
Inheritance
Object    StringExtensions

Methods

BubbleSort Sorts the source IEnumerableT by BubbleSort method.
Contains Returns a value indicating whether the specified string occurs within this string.
ContainsAll(String, IEnumerableString) Determines whether the source string contains all the specified strings.
ContainsAll(String, IEnumerableString, StringComparison) Determines whether the source string contains all the specified strings.
ContainsAny(String, IEnumerableString) Determines whether the source string contains any of the specified strings.
ContainsAny(String, IEnumerableString, StringComparison) Determines whether the source string contains any of the specified strings.
CountEmptyItems Counts the empty items of an IEnumerableT.
CountLines Count the lines in a String.

https://stackoverflow.com/a/33374844/1248295

CountNonEmptyItems Counts the non-empty items of an IEnumerableT.
CountWords Counts the number of words in the input string.
DecodeXml Decodes a encoded XML string.
Delimit(String, String, RegexOptions) Delimits once a string by the given delimiter.
Delimit(String, String, Int32, RegexOptions) Delimits once a string by the given delimiter.
Delimit(String, String, String, RegexOptions) Delimits once a string by the given two delimiters.
Delimit(String, String, String, Int32, RegexOptions) Delimits once a string by the given two delimiters.
EncodeXml Encodes the characters of a string to their equivalent XML character codes.
EndsWithAny(String, IEnumerableString) Determines whether the end of the specified string matches any of the specified strings.
EndsWithAny(String, IEnumerableString, StringComparison) Determines whether the end of the specified string matches any of the specified strings.
EnsureEndsWith(String, String) Determines whether the end of the source string matches the specified string.

If does not, it appends the specified string at the end of the source string.

EnsureEndsWith(String, String, StringComparison) Determines whether the end of the source string matches the specified string.

If does not, it appends the specified string at the end of the source string.

EnsureEquals(String, String) Determines whether the source string equals to the specified string.

If does not, it replaces the source string for the specified string.

EnsureEquals(String, String, StringComparison) Determines whether the source string equals to the specified string.

If does not, it replaces the source string for the specified string.

EnsureStartsWith(String, String) Determines whether the beginning of the source string matches the specified string.

If does not, it inserts the specified string at the beginning of the source string.

EnsureStartsWith(String, String, StringComparison) Determines whether the beginning of the source string matches the specified string.

If does not, it inserts the specified string at the beginning of the source string.

Equals Determines whether the specified object is equal to the current object.
(Inherited from Object)
EqualsAny(String, IEnumerableString) Determines whether the specified string equals to any of the specified strings.
EqualsAny(String, IEnumerableString, StringComparison) Determines whether the specified string equal to any of the specified strings.
EscapeRegEx Escapes any RegEx reserved characters contained in a String.
EscapeXml Escapes any Xml reserved characters contained in a String.
ExpandChars(String, Int32) Expands the characters of a String by adding more white-spaces.
ExpandChars(String, Char, Int32) Expands the characters of a String by adding the specified separator char.
ExpandVariables Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable.
FindByContains Finds the elements that contains the specified string on the source IEnumerableT.
FindByLike Performs a String-Like pattern search on the source IEnumerableT and returns all the matches.
FindExact Finds the elements that are equals to the specified string on the source IEnumerableT.
GetGroupingInfo Gets info about the grooupings of a String.
GetHashCode Serves as the default hash function.
(Inherited from Object)
GetType Gets the Type of the current instance.
(Inherited from Object)
HasDiacritics Determines whether the source Unicode string contains diacritic characters.
IndexOfAll(String, String, StringComparison) Searches for the specified string pattern within the source String, and returns the zero-based index of all the occurrences.
IndexOfAll(String, String, Int32, StringComparison) Searches for the specified string pattern within the source String, and returns the zero-based index of all the occurrences.
IndexOfAll(String, String, Int32, Int32, StringComparison) Searches for the specified string pattern within the source String, and returns the zero-based index of all the occurrences.
IndexOfAnyRegEx(String, IEnumerableString, RegexOptions) Reports the zero-based index of the first occurrence in this instance of any Regex expression in a specified array.
IndexOfAnyRegEx(String, IEnumerableString, Int32, RegexOptions) Reports the zero-based index of the first occurrence in this instance of any Regex expression in a specified array.
IndexOfAnyRegEx(String, IEnumerableString, Int32, Int32, RegexOptions) Reports the zero-based index of the first occurrence in this instance of any Regex expression in a specified array.
IndexOfRegEx(String, String, RegexOptions) Reports the zero-based index of the first occurrence of the specified string in this instance, using a regular expression.
IndexOfRegEx(String, String, Int32, RegexOptions) Reports the zero-based index of the first occurrence of the specified string in this instance, using a regular expression.
IndexOfRegEx(String, String, Int32, Int32, RegexOptions) Reports the zero-based index of the first occurrence of the specified string in this instance, using a regular expression.
IsAlphabetic Determines whether a string is alphabetic.
IsAlphanumeric Determines whether a string is alphanumeric (it should contain at least 1 letter and 1 number).
IsCaseOf Determines wheter a String is written in the specified string case.
IsHexadecimal Determines whether a string is a Hexadecimal string.
IsLikeAny Determines whether the source string matches any of the specified patterns.

The specified pattern can contain exactly the characters to match, or it can contain meta characters, using the wildcard characters.

IsNumeric Determines whether a string is numeric.
IsNumericOfT Determines whether a string is numeric of specified Type.
IsPalindrome Determines whether the specified string is palindrome.
IsUnicodeEscaped Determines whether the source string contains Unicode escape sequences.
IsValidXml Determines whether the source String is a valid XML text.
IsValueOfT Determines whether a string is a valid value of the specified Type.
IsXmlEscaped Determines whether the source String contains Xml escapes.
LastIndexOfAnyRegEx(String, IEnumerableString, RegexOptions) Reports the zero-based index of the last occurrence in this instance of any Regex expression in a specified array.
LastIndexOfAnyRegEx(String, IEnumerableString, Int32, RegexOptions) Reports the zero-based index of the last occurrence in this instance of any Regex expression in a specified array.
LastIndexOfAnyRegEx(String, IEnumerableString, Int32, Int32, RegexOptions) Reports the zero-based index of the last occurrence in this instance of any Regex expression in a specified array.
LastIndexOfRegEx(String, String, RegexOptions) Reports the zero-based index position of the last occurrence of a specified string within this instance, using a regular expression.
LastIndexOfRegEx(String, String, Int32, RegexOptions) Reports the zero-based index position of the last occurrence of a specified string within this instance, using a regular expression.
LastIndexOfRegEx(String, String, Int32, Int32, RegexOptions) Reports the zero-based index position of the last occurrence of a specified string within this instance, using a regular expression.
Measure Provides the Size, in pixels, of the specified text when drawn with the specified font.
NormalizeASCII Normalizes the non-representable characters of the specified ASCII string.
NormalizeDiacritics Transforms the diacritic characters in a string, into standard fully compatible decomposited characters.

For example, having the diacritic "á" character, which its decomposited secuence is: "a" + "´", we return only "a".

NormalizeNewLines Normalize new lines in the source string by replacing them with the specified replacement string.
NormalizeTabs Normalize tabulation characters in the source string by replacing them with the specified replacement string.
NormalizeWhiteSpaces Normalize white-space characters in the source string by replacing them with the specified replacement string.
OccurrencesOf(String, Char) Counts the occurences of the specified character in an String.
OccurrencesOf(String, String) Counts the occurences of the specified string in the source String.
OccurrencesOf(String, Char, StringComparison) Counts the occurences of the specified character in an String.
OccurrencesOf(String, String, StringComparison) Counts the occurences of the specified string in the source String.
OrderByNameNatural Sorts the elements of the source IEnumerableT using natural order.

https://en.wikipedia.org/wiki/Natural_sort_order

PadBoth Returns a new string that center-aligns the characters in the source string by padding them on the left and the right with a specified Unicode character, for a specified total length.
Pluralize(String) Returns the plural form of the specified singular word, in English language.
Pluralize(String, CultureInfo) Returns the plural form of the specified singular word, in the specified language.
Randomize(String) Randomizes a String.
Randomize(String, Int32) Randomizes a String.
Remove Removes characters from the source string, based on a predicate.
RemoveByContains Removes the elements that contains the specified string on the source IEnumerableT.
RemoveByLike Performs a String-Like pattern search on the source IEnumerableT and removes all the matches.
RemoveEnd(String, Int32) Returns a new string in which a specified number of characters in the current String ending at a specified position have been deleted.
RemoveEnd(String, Int32, Int32) Returns a new string in which a specified number of characters in the current String ending at a specified position have been deleted.
RemoveExact Removes the elements that are equals to the specified string on the source IEnumerableT.
Rename Renames a string to the specified StringCase.
Repeat Returns the source string repeated the specified amount of times.
Replace(String, Char, Char, StringComparison) Returns a new string in which all occurrences of the specified character in the current instance are replaced with another specified character using the specified string comparison type.
Replace(String, Char, String, StringComparison) Returns a new string in which all occurrences of the specified character in the current instance are replaced with another specified string using the specified string comparison type.
Replace(String, String, Char, StringComparison) Returns a new string in which all occurrences of the specified strings in the current instance are replaced with another specified character using the specified string comparison type.
Replace(String, String, String, StringComparison) Returns a new string in which all occurrences of the specified strings in the current instance are replaced with another specified string using the specified string comparison type.
ReplaceAll(String, IEnumerableChar, Char) Returns a new string in which all occurrences of the specified characters in the current instance are replaced with another specified character.
ReplaceAll(String, IEnumerableChar, String) Returns a new string in which all occurrences of the specified characters in the current instance are replaced with another specified string.
ReplaceAll(String, IEnumerableString, Char) Returns a new string in which all occurrences of the specified strings in the current instance are replaced with another specified character.
ReplaceAll(String, IEnumerableString, String) Returns a new string in which all occurrences of the specified strings in the current instance are replaced with another specified string.
ReplaceAll(String, IEnumerableChar, Char, StringComparison) Returns a new string in which all occurrences of the specified characters in the current instance are replaced with another specified character using the specified string comparison type.
ReplaceAll(String, IEnumerableChar, String, StringComparison) Returns a new string in which all occurrences of the specified characters in the current instance are replaced with another specified string using the specified string comparison type.
ReplaceAll(String, IEnumerableString, Char, StringComparison) Returns a new string in which all occurrences of the specified strings in the current instance are replaced with another specified string using the specified string comparison type.
ReplaceAll(String, IEnumerableString, String, StringComparison) Returns a new string in which all occurrences of the specified strings in the current instance are replaced with another specified string using the specified string comparison type.
ReplaceAllRegex(String, IEnumerableString, Char, RegexOptions) Returns a new string in which all occurrences of the specified strings in the current instance are replaced with another specified character using a regular expression.
ReplaceAllRegex(String, IEnumerableString, String, RegexOptions) Returns a new string in which all occurrences of the specified strings in the current instance are replaced with another specified string using a regular expression.
ReplaceRegEx(String, String, Char, RegexOptions) Returns a new string in which all occurrences of the specified string in the current instance are replaced with another specified character using a regular expression.
ReplaceRegEx(String, String, String, RegexOptions) Returns a new string in which all occurrences of the specified string in the current instance are replaced with another specified using a regular expression.
Reverse Inverts the order of the characters in a String.
Rotate Rotates the position of the characters in a String.
Singularize(String) Returns the singular form of the specified plural word, in English language.
Singularize(String, CultureInfo) Returns the singular form of the specified plural word, in the specified language.
SizeInFile(String, Encoding) Gets the size, in bytes, of how much a string will occupy when written to a file using the specified Encoding.
SizeInFile(String, Encoding, Boolean) Gets the size, in bytes, of how much a string will occupy when written to a file using the specified Encoding.
SizeInMemory Gets the size, in bytes, that occupies a string in memory using UTF-16 encoding.
Split(String, String, StringSplitOptions) Splits a string into substrings that are based on the specified string.

You can specify whether the substrings include empty array elements.

Split(String, String, Int32, StringSplitOptions) Splits a string into a maximum number of substrings based on the specified string.

You can specify whether the substrings include empty array elements.

SplitByLength Split a String into parts of the specified length.
SplitByPosition Split a String into two parts by the specified character position.
StartsWithAny(String, IEnumerableString) Determines whether the beginning of the specified string matches any of the specified strings.
StartsWithAny(String, IEnumerableString, StringComparison) Determines whether the beginning of the specified string matches any of the specified strings.
SubstringEnd(String, Int32) Retrieves a substring from the source String.

The substring starts at the end of the string.

SubstringEnd(String, Int32, Int32) Retrieves a substring from the source String.

The substring starts at the end of the string.

ToByteArray Converts a string to a Byte array.
ToSecureString Converts the source String to a SecureString.
ToString Returns a string that represents the current object.
(Inherited from Object)
ToTreeString Transforms an array of string into a string with tree formatting.
Transliterate Transliterates the specified characters or words in the source String.

https://en.wikipedia.org/wiki/Transliteration

TransliterateFullWords(String, SortedDictionaryString, String, StringComparison) Transliterates full words in the source String.

By default, these characters are used to delimit words: " .:,;\/!¡|·()=?¿+_*[]{}"¨<>"

https://en.wikipedia.org/wiki/Transliteration

TransliterateFullWords(String, SortedDictionaryString, String, Char, StringComparison) Transliterates full words in the source String.

https://en.wikipedia.org/wiki/Transliteration

Truncate Truncates the source string to a specified length and replaces the truncated part with an ellipsis.
TruncateMiddle Truncates the source string to a specified length by stripping out the center and replacing it with an ellipsis, so that the beginning and end of the string are retained.
UnescapeRegEx Unescapes any RegEx reserved characters contained in a String.
UnescapeUnicode Converts any unicode escape sequence in the specified string to its corresponding unicode characters.
UnescapeXml Unescapes any Xml reserved characters contained in a String.
WithDoubleQuotes Returns a copy of the source string enclosed in double-quotes at the beginning and the end of the string.
WithQuotes Returns a copy of the source string enclosed in quotes at the beginning and the end of the string.
WordWrap(String, Int32, Boolean) Wraps the input text into multiple lines whose words will fit into the specified line length.
WordWrap(String, Int32, Font) Wraps words of the source String to the beginning of the next line when necessary to fit the specified pixel width.

Extension Methods

CanConvertTo Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions)
CanConvertToT Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions)
ConvertToT Converts an object to the specified target type.

If the conversion fails, an exception is thrown.
(Defined by ObjectExtensions)

ConvertToT Converts an object to the specified target type.

If the conversion fails, returns the specified default value.
(Defined by ObjectExtensions)

IsDisposable Determines whether the specified object is a disposable type (i.e., it implements IDisposable interface).
(Defined by ObjectExtensions)
Speak Speaks the string representation of the source object by using the operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions)
Speak Speaks the string representation of the source object by using the operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions)
ThrowIfNullTException Throws the specified exception if the source object is null.
(Defined by ObjectExtensions)

See Also