MemoryExtensionsStripPrefix(ReadOnlyMemoryChar, ReadOnlySpanChar, CultureInfo, CompareOptions) Method

Removes a prefix from a read-only memory region of characters.

Definition

Namespace: Ookii.Common
Assembly: Ookii.Common (in Ookii.Common.dll) Version: 1.0.0+7c2900b8a16cd8ae46bdd79d8f105034712c5fa3
C#
public static ReadOnlyMemory<char>? StripPrefix(
	this ReadOnlyMemory<char> memory,
	ReadOnlySpan<char> prefix,
	CultureInfo culture,
	CompareOptions options = CompareOptions.None
)

Parameters

memory  ReadOnlyMemoryChar
The memory region of characters to remove the prefix from.
prefix  ReadOnlySpanChar
The prefix to remove.
culture  CultureInfo
The CultureInfo to use to match the prefix.
options  CompareOptions  (Optional)
The options to use for the string comparison.

Return Value

NullableReadOnlyMemoryChar
If memory starts with prefix, returns the memory region without the prefix; otherwise, returns .

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ReadOnlyMemoryChar. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

When using the .Net Standard 2.0 or 2.1 version of this library, this method may allocate strings to perform the comparison. This is because the CompareInfo class does not provide string comparison methods for use with ReadOnlyMemoryT.

See Also