Class StringExtensions
A static class that contains extension methods for the System.String class.
Inheritance
Inherited Members
Namespace: Juhta.Net.Extensions
Assembly: Juhta.Net.dll
Syntax
public static class StringExtensions
Methods
| Improve this Doc View SourceContainsWhitespaces(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. |
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 |
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 |
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.
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. |
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.
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. |
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.
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. |
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. |
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. |
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 |
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 |
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 |
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 |
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.
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.