StringExtensions Class

Namespace:
Weavy.Core.Helpers
Assembly:
Weavy.Core.dll

Helper and extension methods for manipulating strings.

public static class StringExtensions
Inheritance:
System.Object → StringExtensions

Fields

QuotePattern A regular expression pattern for matching quotes.

Methods

AddLeading(String, String) Appends a string before the text if it does not already exist.
AddTrailing(String, String) Appends a string after the text if it does not already exist.
AddTrailingSlash(String) Adds a slash after the text if it does not already exist.
AsEnum(String) Helper method for converting a string to an enum of type TEnum.
AsNullableBool(String) Helper method for converting a string to a nullable bool.
AsNullableDateTime(String) Helper method for converting a string to a nullable date.
AsNullableGuid(String) Helper method for converting a string to a nullable Guid.
AsNullableInt(String) Helper method for converting a string to a nullable int.
AsNullableLong(String) Helper method for converting a string to a nullable long.
Base64Decode(String, Boolean) Decodes a base-64 string.
Base64Encode(String, Boolean) Encodes a string to base-64.
Contains(String, String, StringComparison) Returns true if the the specified string contains the contained string.
Ellipsis(String, Int32) Trims a string after a specific length and appends the horizontal ellipsis character (U+2026) to the end of the string.
ExtractQuote(String, Boolean) Returns content of first quote in input string.
FormatNumericCode(String) Format a numeric code, e.g. 884902 -> 884-902
FormatWith(String, Object[]) Extension method that wraps string.Format().
GetIndefinateArticle(String) Naive attempt to get the indefinite article of a noun.
IsNullOrEmpty(String) Indicates if the specified string is null or an empty string.
IsNullOrWhiteSpace(String) Indicates if the specified string is null, empty or consists only of white-space characters.
IsValidCultureName(String) Returns a value indicating if the
string
is a valid language culture name.
Left(String, Int32) Returns a string containing a specified number of characters from the left side of a string.
LeftBefore(String, String, NullableComparison>) Returns a string containing every character within a string before the first occurrence of another string.
LeftBeforeLast(String, String, NullableComparison>) Returns a string containing every character within a string before (left) the last occurrence of another string.
NamedFormat(String, Object) Formats a string with named parameters instead of indexed.
PastTense(String) Returns the past tense of the specified verb.
Quote(String, Boolean) Surrounds the string with quotation marks.
RandomAscii(Int32, Int32, Int32, Int32, Int32, Boolean) Generates a random ascii string.
RemoveDoubleCharacter(String, Char) Removes any double instances of the specified character. So "--" becomes "-" if the character is '-'.
RemoveLeading(String, String, NullableComparison>) Removes leading text from a string.
RemoveTrailing(String, String, NullableComparison>) Removes trailing text from a string.
RemoveTrailingSlash(String) Removes trailing slash from a string.
Replicate(String, Int32) Repeats the specified string a specified number of times.
Reverse(String) Reverses a string.
Right(String, Int32) Returns a string containing a specified number of characters from the right side of a string.
RightAfter(String, String, NullableComparison>) Returns a string containing every character within a string after the first occurrence of another string.
RightAfterLast(String, String, Int32, NullableComparison>) Returns a string containing every character within a string after the last occurrence of another string.
RightAfterLast(String, String, NullableComparison>) Returns a string containing every character within a string after the last occurrence of another string.
SingularizeOrPluralize(Nullable, String, String, Boolean) Returns a string with the number of items and the singular or plural postfix.
SingularizeOrPluralize(IEnumerable, String, String, Boolean) Returns a string with the number of items in the collection and the singular of plural postfix.
Slugify(String, Boolean) Returns a URL friendly version of the input string.
SplitAndTrim(String) Splits a comma separated string and trims leading and trailing whitespace characters.
SplitTags(String) Split a comma separated string into an alphabetically sorted list of tags.
SplitUppercase(String) Parses a camel cased or pascal cased string and returns an array of the words within the string.
ToCamelCase(String, Boolean) Returns the camelCased version of a string. See http://en.wikipedia.org/wiki/Camel_case.
ToQueryString(String) Parses a query string into a System.Collections.Specialized.NameValueCollection using UTF8 encoding.
ToSentenceCase(String) Returns the sentence cased version of a string, i.e. a string where the first letter of the first word is capitalized.
ToSnakeCase(String) Returns the snake_cased version of a string. See http://en.wikipedia.org/wiki/Snake_case.
ToSpaceCase(String) Returns the space-cased version of a string. Space case is similar to snake_case, but underscores are replaced with spaces.
ToSpinalCase(String) Returns the spinal-cased version of a string. Spinal case is similar to snake_case, but underscores are replaced with dashes.
ToTitleCase(String, Boolean) Converts text to title case.
Transliterate(String) Transliterate a Unicode string into ASCII.
TrimInside(String, Boolean) Removes all duplicate white-space (replacing it with single space) from the string. Also removes all leading and trailing whitespace.
Truncate(String, Int32) Trims a string after a specific length.
Usernameify(String) Strips invalid username characters from a string.