Show / Hide Table of Contents

Class StringExtensions

A static class that contains extension methods for the System.String class.

Inheritance
System.Object
StringExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Juhta.Net.Extensions
Assembly: Juhta.Net.dll
Syntax
public static class StringExtensions

Methods

| Improve this Doc View Source

ContainsWhitespaces(String)

Checks whether this string contains white space characters.

Declaration
public static bool ContainsWhitespaces(this string s)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

Returns
Type Description
System.Boolean

Returns true if this string contains white space characters, otherwise false.

| Improve this Doc View Source

EnsureEnd(String, String)

Ensures this string to end with a specified string.

Declaration
public static string EnsureEnd(this string s, string end)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

System.String end

Specifies a string with which this string is ensured to end with.

Returns
Type Description
System.String

Returns such copy of this string that ends with end.

| Improve this Doc View Source

EnsureEnd(String, String, StringComparison)

Ensures this string to end with a specified string.

Declaration
public static string EnsureEnd(this string s, string end, StringComparison stringComparison)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

System.String end

Specifies a string with which this string is ensured to end with.

System.StringComparison stringComparison

Specifies a StringComparison value.

Returns
Type Description
System.String

Returns such copy of this string that ends with end.

| Improve this Doc View Source

FromBase64String(String)

Converts this base64 string to its equivalent string.

Declaration
public static string FromBase64String(this string s)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

Returns
Type Description
System.String

Returns the string representation of this base64 string.

Remarks

This method performs string conversions through the UTF-8 encoding.

| Improve this Doc View Source

IsRegexMatch(String, String)

Checks whether a specified regular expression pattern matches this string.

Declaration
public static bool IsRegexMatch(this string s, string pattern)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

System.String pattern

Specifies a regular expression pattern.

Returns
Type Description
System.Boolean

Returns true if the specified regular expression pattern matches this string, otherwise false.

| Improve this Doc View Source

RemoveEnd(String, String)

Removes a specified end from this string.

Declaration
public static string RemoveEnd(this string s, string end)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

System.String end

Specifies a string that will be removed from the end of this string.

Returns
Type Description
System.String

Returns such copy of this string from which the specified end has been removed. If this string doesn't end with the specified end, returns a copy of this string.

Remarks

This method is case-sensitive.

| Improve this Doc View Source

RemoveEnd(String, String, StringComparison)

Removes a specified end from this string.

Declaration
public static string RemoveEnd(this string s, string end, StringComparison stringComparison)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

System.String end

Specifies a string that will be removed from the end of this string.

System.StringComparison stringComparison

Specifies a StringComparison value.

Returns
Type Description
System.String

Returns such copy of this string from which the specified end has been removed. If this string doesn't end with the specified end, returns a copy of this string.

| Improve this Doc View Source

RemoveStart(String, String)

Removes a specified start from this string.

Declaration
public static string RemoveStart(this string s, string start)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

System.String start

Specifies a string that will be removed from the start of this string.

Returns
Type Description
System.String

Returns such copy of this string from which the specified start has been removed. If this string doesn't start with the specified start, returns a copy of this string.

Remarks

This method is case-sensitive.

| Improve this Doc View Source

RemoveStart(String, String, StringComparison)

Removes a specified start from this string.

Declaration
public static string RemoveStart(this string s, string start, StringComparison stringComparison)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

System.String start

Specifies a string that will be removed from the start of this string.

System.StringComparison stringComparison

Specifies a StringComparison value.

Returns
Type Description
System.String

Returns such copy of this string from which the specified start has been removed. If this string doesn't start with the specified start, returns a copy of this string.

| Improve this Doc View Source

ReplaceHtmlSpecialCharacters(String)

Replaces all HTML special characters with their corresponding entities in this string.

Declaration
public static string ReplaceHtmlSpecialCharacters(this string s)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

Returns
Type Description
System.String

Returns such copy of this string where all occurrences of HTML special characters have been replaced with their corresponding entities.

| Improve this Doc View Source

ReplaceXmlSpecialCharacters(String)

Replaces all XML special characters with their corresponding entities in this string.

Declaration
public static string ReplaceXmlSpecialCharacters(this string s)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

Returns
Type Description
System.String

Returns such copy of this string where all occurrences of XML special characters have been replaced with their corresponding entities.

| Improve this Doc View Source

SubstringAfter(String, Char, StringComparison)

Gets a substring from this string after the first occurrence of a specified character.

Declaration
public static string SubstringAfter(this string s, char value, StringComparison comparison)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

System.Char value

Specifies a character to find.

System.StringComparison comparison

Specifies a comparison mode.

Returns
Type Description
System.String

If value is found within the current string, returns the substring from the current string after the first occurrence of value. If value is not found, returns the current string; this will be done also when value is null or empty.

| Improve this Doc View Source

SubstringAfter(String, String, StringComparison)

Gets a substring from this string after the first occurrence of a specified string.

Declaration
public static string SubstringAfter(this string s, string value, StringComparison comparison)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

System.String value

Specifies a string to find.

System.StringComparison comparison

Specifies a comparison mode.

Returns
Type Description
System.String

If value is found within the current string, returns the substring from the current string after the first occurrence of value. If value is not found, returns the current string; this will be done also when value is null or empty.

| Improve this Doc View Source

SubstringBefore(String, Char, StringComparison)

Gets a substring from this string before the first occurrence of a specified character.

Declaration
public static string SubstringBefore(this string s, char value, StringComparison comparison)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

System.Char value

Specifies a character to find.

System.StringComparison comparison

Specifies a comparison mode.

Returns
Type Description
System.String

If value is found within the current string, returns the substring from the current string before the first occurrence of value. If value is not found, returns the current string; this will be done also when value is null or empty.

| Improve this Doc View Source

SubstringBefore(String, String, StringComparison)

Gets a substring from this string before the first occurrence of a specified string.

Declaration
public static string SubstringBefore(this string s, string value, StringComparison comparison)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

System.String value

Specifies a string to find.

System.StringComparison comparison

Specifies a comparison mode.

Returns
Type Description
System.String

If value is found within the current string, returns the substring from the current string before the first occurrence of value. If value is not found, returns the current string; this will be done also when value is null or empty.

| Improve this Doc View Source

ToBase64String(String)

Converts this string to its equivalent base64 string.

Declaration
public static string ToBase64String(this string s)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

Returns
Type Description
System.String

Returns the base64 string representation of this string.

Remarks

This method performs base64 string conversions through the UTF-8 encoding.

| Improve this Doc View Source

ToBoolean(String)

Converts this string to an equivalent System.Boolean value.

Declaration
public static bool ToBoolean(this string s)
Parameters
Type Name Description
System.String s

Specifies the current string instance.

Returns
Type Description
System.Boolean

Returns this string as an equivalent System.Boolean value.

Remarks

This method is otherwise equivalent to System.Convert.ToBoolean(System.String), but it also accepts the values "1" and "0" as valid string representatives for the boolean values True and False, respectively.

  • Improve this Doc
  • View Source
Back to top Copyright © 2017-2019 Juha Lähteenmäki
Generated by DocFX