Editare

Partajați prin


MemoryExtensions.SplitAny Method

Definition

Overloads

SplitAny(ReadOnlySpan<Char>, Span<Range>, ReadOnlySpan<Char>, StringSplitOptions)

Parses the source ReadOnlySpan<T> for one of the specified separators, populating the destination span with Range instances representing the regions between the separators.

SplitAny(ReadOnlySpan<Char>, Span<Range>, ReadOnlySpan<String>, StringSplitOptions)

Parses the source ReadOnlySpan<T> for one of the specified separators, populating the destination span with Range instances representing the regions between the separators.

SplitAny<T>(ReadOnlySpan<T>, SearchValues<T>)

Returns a type that allows for enumeration of each element within a split span using the provided separator characters.

SplitAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Returns a type that allows for enumeration of each element within a split span using any of the provided elements.

SplitAny(ReadOnlySpan<Char>, Span<Range>, ReadOnlySpan<Char>, StringSplitOptions)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Parses the source ReadOnlySpan<T> for one of the specified separators, populating the destination span with Range instances representing the regions between the separators.

public static int SplitAny (this ReadOnlySpan<char> source, Span<Range> destination, ReadOnlySpan<char> separators, StringSplitOptions options = System.StringSplitOptions.None);
static member SplitAny : ReadOnlySpan<char> * Span<Range> * ReadOnlySpan<char> * StringSplitOptions -> int
<Extension()>
Public Function SplitAny (source As ReadOnlySpan(Of Char), destination As Span(Of Range), separators As ReadOnlySpan(Of Char), Optional options As StringSplitOptions = System.StringSplitOptions.None) As Integer

Parameters

source
ReadOnlySpan<Char>

The source span to parse.

destination
Span<Range>

The destination span into which the resulting ranges are written.

separators
ReadOnlySpan<Char>

Any number of characters that may delimit the regions in this instance. If empty, all Unicode whitespace characters are used as the separators.

options
StringSplitOptions

A bitwise combination of the enumeration values that specifies whether to trim whitespace and include empty ranges.

Returns

The number of ranges written into destination.

Remarks

Delimiter characters are not included in the elements of the returned array.

If the destination span is empty, or if the options specifies RemoveEmptyEntries and source is empty, or if options specifies both RemoveEmptyEntries and TrimEntries and the source is entirely whitespace, no ranges are written to the destination.

If the span does not contain any of the separators, or if destination's length is 1, a single range will be output containing the entire source, subject to the processing implied by options.

If there are more regions in source than will fit in destination, the first destination length minus 1 ranges are stored in destination, and a range for the remainder of source is stored in destination.

Applies to

SplitAny(ReadOnlySpan<Char>, Span<Range>, ReadOnlySpan<String>, StringSplitOptions)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Parses the source ReadOnlySpan<T> for one of the specified separators, populating the destination span with Range instances representing the regions between the separators.

public static int SplitAny (this ReadOnlySpan<char> source, Span<Range> destination, ReadOnlySpan<string> separators, StringSplitOptions options = System.StringSplitOptions.None);
static member SplitAny : ReadOnlySpan<char> * Span<Range> * ReadOnlySpan<string> * StringSplitOptions -> int
<Extension()>
Public Function SplitAny (source As ReadOnlySpan(Of Char), destination As Span(Of Range), separators As ReadOnlySpan(Of String), Optional options As StringSplitOptions = System.StringSplitOptions.None) As Integer

Parameters

source
ReadOnlySpan<Char>

The source span to parse.

destination
Span<Range>

The destination span into which the resulting ranges are written.

separators
ReadOnlySpan<String>

Any number of strings that may delimit the regions in this instance. If empty, all Unicode whitespace characters are used as the separators.

options
StringSplitOptions

A bitwise combination of the enumeration values that specifies whether to trim whitespace and include empty ranges.

Returns

The number of ranges written into destination.

Remarks

Delimiter characters are not included in the elements of the returned array.

If the destination span is empty, or if the options specifies RemoveEmptyEntries and source is empty, or if options specifies both RemoveEmptyEntries and TrimEntries and the source is entirely whitespace, no ranges are written to the destination.

If the span does not contain any of the separators, or if destination's length is 1, a single range will be output containing the entire source, subject to the processing implied by options.

If there are more regions in source than will fit in destination, the first destination length minus 1 ranges are stored in destination, and a range for the remainder of source is stored in destination.

Applies to

SplitAny<T>(ReadOnlySpan<T>, SearchValues<T>)

Returns a type that allows for enumeration of each element within a split span using the provided separator characters.

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static MemoryExtensions::SpanSplitEnumerator<T> SplitAny(ReadOnlySpan<T> source, System::Buffers::SearchValues<T> ^ separators);
public static MemoryExtensions.SpanSplitEnumerator<T> SplitAny<T> (this ReadOnlySpan<T> source, System.Buffers.SearchValues<T> separators) where T : IEquatable<T>;
static member SplitAny : ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> * System.Buffers.SearchValues<'T (requires 'T :> IEquatable<'T>)> -> MemoryExtensions.SpanSplitEnumerator<'T (requires 'T :> IEquatable<'T>)> (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function SplitAny(Of T As IEquatable(Of T)) (source As ReadOnlySpan(Of T), separators As SearchValues(Of T)) As MemoryExtensions.SpanSplitEnumerator(Of T)

Type Parameters

T

The type of the elements.

Parameters

source
ReadOnlySpan<T>

The source span to be enumerated.

separators
SearchValues<T>

The SearchValues<T> to be used to split the provided span.

Returns

An enumerator that can be used to enumerate each element in a split span using the provided separator characters.

Remarks

Unlike SplitAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>), separators is not checked for being empty.

An empty separators argument will result in no separators being found, regardless of the type of T, whereas SplitAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) uses all Unicode whitespace characters as separators if separators is empty and T is Char.

Applies to

SplitAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Returns a type that allows for enumeration of each element within a split span using any of the provided elements.

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static MemoryExtensions::SpanSplitEnumerator<T> SplitAny(ReadOnlySpan<T> source, ReadOnlySpan<T> separators);
public static MemoryExtensions.SpanSplitEnumerator<T> SplitAny<T> (this ReadOnlySpan<T> source, ReadOnlySpan<T> separators) where T : IEquatable<T>;
static member SplitAny : ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> * ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> -> MemoryExtensions.SpanSplitEnumerator<'T (requires 'T :> IEquatable<'T>)> (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function SplitAny(Of T As IEquatable(Of T)) (source As ReadOnlySpan(Of T), separators As ReadOnlySpan(Of T)) As MemoryExtensions.SpanSplitEnumerator(Of T)

Type Parameters

T

The type of the elements.

Parameters

source
ReadOnlySpan<T>

The source span to be enumerated.

separators
ReadOnlySpan<T>

The separators to be used to split the provided span.

Returns

An enumerator that can be used to enumerate each element in a split span using the provided separator characters.

Remarks

If T is Char and if separators is empty, all Unicode whitespace characters are used as the separators. This matches the behavior of when Split(Char[]) and related overloads are used with an empty separator array, or when SplitAny(ReadOnlySpan<Char>, Span<Range>, ReadOnlySpan<Char>, StringSplitOptions) is used with an empty separator span.

Applies to