StringUtils Class

Version 1.1.28
.NET Framework 4.8
Namespace Skybrud.Essentials.Strings
Assembly Skybrud.Essentials.dll
Visibility Public
Keywords Static
Inheritance Object

Utility class with various static helper methods for working with strings.

public static class StringUtils { }

Methods

CsvToInt(string) (static)

Converts a comma separated string into an array of integers.

Uppercases the first character of a the specified str. If str is either null or empty, an empty string will be returned instead.

Highlights specified keywords in the input string with the specified className by using a <span> element.

Highlights specified keywords in the input string with the specified className by using a <span> element.

HTML decodes the specified str.

HTML encodes the specified str.

Returns whether the specified value is alphabetic - meaning it only consists of letters.

Gets whether the specified string is alphanumeric - meaning it only consists of numbers and letters.

IsDouble(string) (static)

Gets whether the string matches a double (Double ).

IsFloat(string) (static)

Gets whether the string matches an integer (Single ).

IsGuid(string) (static)

Gets whether the string matches a GUID (Guid ).

IsInt32(string) (static)

Gets whether the string matches an integer (int ).

IsInt64(string) (static)

Gets whether the string matches a long (long ).

Alias of Skybrud.Essentials.Strings.StringUtils.IsDouble(System.String). Gets whether the string matches a double (Double ).

Computes the Levenshtein distance between two strings.

The Levenshtein distance is defined as the minimal number of characters you have to replace, insert or delete to transform s into t.

Parses the specified str into an instance of bool . The string is considered true if it matches either true, 1, t or on (case insensitive).

Parses the specified str into an instance of bool . The string is considered true if it matches either true, 1, t or on, or false if it matches either false, 0, f or off. All comparisons are case insensitive.

Parses the specified value into an instance of bool . The value is considered true if it matches either true, 1, t or on (case insensitive).

Parses the specified value into an instance of bool . The string is considered true if it matches either true, 1, t or on, or false if it matches either false, 0, f or off. All comparisons are case insensitive.

Parses the specified str into an instance of Double . If the parsing fails, the default value of Double will be returned instead.

Parses the specified str into an instance of Double . If the parsing fails, fallback will be returned instead.

Parses a string of integer values into an array of Double . Supported separators are ,, , \r, \n and \t. Values in the list that can't be converted to Double will be ignored.

Parses a string of double values into an array of Double . Values in the list that can't be converted to Double will be ignored.

Parses the specified str into an instance of Single . If the parsing fails, the default value of Single will be returned instead.

Parses the specified str into an instance of Single . If the parsing fails, fallback will be returned instead.

Parses the specified str into an instance of Single . If the parsing fails, fallback will be returned instead.

Parses a string of float values into an array of Single . Supported separators are ,, , \r, \n and \t. Values in the list that can't be converted to Single will be ignored.

Parses a string of float values into an array of Single . Values in the list that can't be converted to Single will be ignored.

Parses the specified str into an instance of Guid . If the parsing fails, the default value of Guid will be returned instead.

Parses the specified str into an instance of Guid . If the parsing fails, fallback will be returned instead.

Parses a string of multiple GUIDs into an array of Guid . Supported separators are comma (,), space (), carriage return (\r), new line (\n) and tab (\t).

Values in str that can't be converted to Guid will be ignored.

Parses string of multiple GUIDs into an array of Guid , using the specified array of separators.

Values in str that can't be converted to Guid will be ignored.

Parses the specified str into an instance of int . If the parsing fails, the default value of int will be returned instead.

Parses the specified str into an instance of int . If the parsing fails, fallback will be returned instead.

Parses a string of integer values into an array of int . Supported separators are ,, , \r, \n and \t. Values in the list that can't be converted to int will be ignored.

Parses a string of integer values into an array of int . Values in the list that can't be converted to int will be ignored.

Parses the specified str into an instance of long . If the parsing fails, the default value of long will be returned instead.

Parses the specified str into an instance of long . If the parsing fails, fallback will be returned instead.

Parses a string of numeric values into an array of long . Supported separators are ,, , \r, \n and \t. Values in the list that can't be converted to long will be ignored.

Parses a string of numeric values into an array of long . Values in the list that can't be converted to long will be ignored.

Parses string of multiple values into an array of String . Supported separators are comma (,), space (), carriage return (\r), new line (\n) and tab (\t).

Empty entries are automatically removed from the output array.

Parses string of multiple values into an array of String , using the specified array of separators.

Empty entries are automatically removed from the output array.

HTML encodes the text and replaces text line breaks with HTML line breaks.

Strips all HTML elements from the specified html string.

Strips all HTML elements from the specified html string, but keeps the HTML tags as specified in ignore.

Converts the specified str to camel case (also referred to as lower camel casing).

Converts the name of the specified enum value to a camel cased string.

Converts the specified enum value to a string with the enum name is formatted using the specified casing.

Converts the specified str to a new string formatted using the specified casing.

Converts the specified str to a kebab cased string (lower case words separated by hyphens).

Converts the name of the specified enum value to a kebab cased string (lower case words separated by hyphens).

ToLower(Enum) (static)

Converts the specified enum value to a lower case string.

Converts the specified str to Pascal case (also referred to as upper camel casing).

Converts the name of the specified enum value to a Pascal cased string.

ToPlural(string) (static)

Converts a singular word to the plural counterpart (for English words only).

Converts a plural word to the singular counterpart (for English words only).

Converts the specified str to a train cased string (upper case words separated by hyphens).

Converts the name of the specified enum value to a train cased string (upper case words separated by hyphens).

Converts the specified str to a lower case string with words separated by underscores.

Converts the specified enum value to a lower case string with words separated by underscores.

ToUpper(Enum) (static)

Converts the specified enum value to an upper case string.

Tries to convert the specified string representation of a logical value to its bool equivalent.

URL decodes a URL string.

URL encodes the specified str.

Counts number of words in the specified str.