Coree.NETStandard
  • API
Show / Hide Table of Contents
  • Coree.NETStandard.Abstractions
    • DependencySingleton<T>
    • FluentBase
    • IDependencySingleton
    • IFluentBase
  • Coree.NETStandard.Classes
    • ThreadSafeCollection<T>
    • ThreadSafeValue<T>
  • Coree.NETStandard.CoreeHttpClient
    • CoreeHttpClient
    • CoreeHttpClient2
    • HttpHeadersExtensions
    • HttpRequestHeadersExtensions
    • HttpResponseResult
    • HttpResponseResult.OperationStatus
    • HttpResponseResult2
    • HttpResponseResult2.OperationStatus
    • ICoreeHttpClient
    • Product
    • ProductExtensions
    • RequestContentBuilder
    • RequestParamBuilder
    • ServiceCollectionExtensions
    • UriExtensions
  • Coree.NETStandard.Extensions
    • BoolExtensions
    • CancellationTokenExtensions
    • EnumerableStringExtension
    • EnumerableTExtension
    • HostApplicationBuilderExtensions
    • ServiceProviderExtensions
    • StringBuilderExtension
    • StringsExtensions
  • Coree.NETStandard.HostedServicesCollection
    • HostedServicesCollectionConfig<T>
    • IHostedServicesCollectionConfig<T>
    • ServiceCollectionExtensions
    • ServiceProviderExtensions
  • Coree.NETStandard.Serilog
    • ConditionalLevelSink
    • LoggerSinkConfigurationExtensions
    • OutputTemplates
    • ServiceCollectionExtensions
    • SourceContextShortEnricher
  • Coree.NETStandard.Services
    • IRuntimeInsights
    • RuntimeInsightsService
  • Coree.NETStandard.Services.File
    • FileService
    • IFileService
  • Coree.NETStandard.Services.Process
    • IProcessService
    • ProcessRunExitCodeState
    • ProcessRunResult
    • ProcessService
  • Coree.NETStandard.Services.RuntimeInsights
    • IRuntimeInsightsService
    • RuntimeInsightsService
  • Coree.NETStandard.SpectreConsole
    • CommandAppExtensions
    • HostBuilderExtensions
    • ServiceCollectionExtensions
    • SpectreConsoleHostedService
    • SpectreConsoleHostedService.ExitCode
    • SpectreConsoleTypeRegistrar
    • SpectreConsoleTypeResolver
  • Coree.NETStandard.Utilities
    • MainContext

Class StringsExtensions

Provides extension methods for string operations, enhancing the built-in string manipulation capabilities.

Inheritance
object
StringsExtensions
Namespace: Coree.NETStandard.Extensions
Assembly: Coree.NETStandard.dll
Syntax
public static class StringsExtensions

Methods

| Edit this page View Source

IsValidJson(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.

| Edit this page View Source

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.

| Edit this page View Source

SplitWith(string?, char[], StringSplitOptions, bool)

Splits the input string by an array of characters, treating them as individual delimiters, with options to control the split operation. Offers the option to remove the delimiters from the resulting array.

Declaration
public static string[] SplitWith(this string? input, char[] delimiter, StringSplitOptions options = StringSplitOptions.None, bool removeDelimiters = true)
Parameters
Type Name Description
string input

The string to be split.

char[] delimiter

The array of characters joined to a string to use as delimiter

StringSplitOptions options

Specifies whether to omit empty or whitespace-only substrings from the resulting array.

bool removeDelimiters

When set to true, the delimiters themselves are excluded from the result array.

Returns
Type Description
string[]

An array of substrings that are delimited by the specified characters, optionally excluding the delimiters themselves.

Remarks

This method constructs a string from the character array and uses regular expressions for splitting, which may have performance implications for large strings or a large number of delimiters. When removeDelimiters is true, it filters out any substring that matches one of the delimiters exactly, after splitting.

| Edit this page View Source

SplitWith(string?, string, StringSplitOptions, bool)

Splits the input string by a specified string delimiter, with options to control the split operation. Offers the option to remove the delimiter from the resulting array.

Declaration
public static string[] SplitWith(this string? input, string delimiter, StringSplitOptions options = StringSplitOptions.None, bool removeDelimiters = true)
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.

bool removeDelimiters

When set to true, the delimiter itself is excluded from the result array.

Returns
Type Description
string[]

An array of substrings that are delimited by the specified string, optionally excluding the delimiter itself.

Remarks

This method uses regular expressions to split the input string, which may have performance implications for large strings or a large number of delimiters. When removeDelimiters is true, it filters out the delimiter if it matches exactly, after splitting.

| Edit this page View Source

SplitWith(string?, string[], StringSplitOptions, bool)

Splits the input string by multiple string delimiters, with options to control the split operation. Offers the option to remove the delimiters from the resulting array.

Declaration
public static string[] SplitWith(this string? input, string[] delimiters, StringSplitOptions options = StringSplitOptions.None, bool removeDelimiters = true)
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.

bool removeDelimiters

When set to false, the delimiters themselves are not excluded from the result array.

Returns
Type Description
string[]

An array of substrings that are delimited by any of the specified strings, optionally excluding the delimiters themselves.

Remarks

This method uses regular expressions to split the input string, which may have performance implications for large strings or a large number of delimiters. When removeDelimiters is true, it filters out any substring that matches one of the delimiters exactly, after splitting.

  • Edit this page
  • View Source
In this article
Back to top