Class StringExtensions
Provides extension methods for string operations, enhancing the built-in string manipulation capabilities.
Namespace: Coree.NETStandard.Extensions.Strings
Assembly: Coree.NETStandard.dll
Syntax
public static class StringExtensions
Methods
| Edit this page View SourceIsValidJson(string)
Validates whether the specified string is valid JSON.
Declaration
public static bool IsValidJson(this string jsonString)
Parameters
Type | Name | Description |
---|---|---|
string | jsonString | The JSON string to validate. |
Returns
Type | Description |
---|---|
bool | true if the string is valid JSON; otherwise, false. |
IsValidXml(string)
Validates whether the specified string is well-formed XML.
Declaration
public static bool IsValidXml(this string xmlString)
Parameters
Type | Name | Description |
---|---|---|
string | xmlString | The XML string to validate. |
Returns
Type | Description |
---|---|
bool | true if the string is a well-formed XML; otherwise, false. |
SplitWith(string?, char[], StringSplitOptions)
Splits the input string by an array of characters, treating them as a single connected delimiter, with options to control the split operation.
Declaration
public static string[] SplitWith(this string? input, char[] delimiter, StringSplitOptions options = StringSplitOptions.None)
Parameters
Type | Name | Description |
---|---|---|
string | input | The string to be split. |
char[] | delimiter | The array of characters to form the delimiter. |
StringSplitOptions | options | Specifies whether to omit empty or whitespace-only substrings from the resulting array. |
Returns
Type | Description |
---|---|
string[] | An array of substrings that are delimited by the specified sequence of characters. |
SplitWith(string?, string, StringSplitOptions)
Splits the input string by a specified string delimiter, with options to control the split operation.
Declaration
public static string[] SplitWith(this string? input, string delimiter, StringSplitOptions options = StringSplitOptions.None)
Parameters
Type | Name | Description |
---|---|---|
string | input | The string to be split. |
string | delimiter | The string delimiter to split by. |
StringSplitOptions | options | Specifies whether to omit empty or whitespace-only substrings from the resulting array. |
Returns
Type | Description |
---|---|
string[] | An array of substrings that are delimited by the specified string. |
SplitWith(string?, string[], StringSplitOptions)
Splits the input string by multiple string delimiters, with options to control the split operation.
Declaration
public static string[] SplitWith(this string? input, string[] delimiters, StringSplitOptions options = StringSplitOptions.None)
Parameters
Type | Name | Description |
---|---|---|
string | input | The string to be split. |
string[] | delimiters | The array of string delimiters to split by. |
StringSplitOptions | options | Specifies whether to omit empty or whitespace-only substrings from the resulting array. |
Returns
Type | Description |
---|---|
string[] | An array of substrings that are delimited by any of the specified strings. |