Skip to content

Regex.Count Method

Definition

Namespace: Corvus.Ecma262.RegularExpressions
Assembly: Corvus.Regex.Ecma262.dll

Overloads

Method Description
Count(string) The number of matches in a text.
Count(ReadOnlySpan<char>) The number of matches in a UTF-16 text, allocating nothing.
Count(ReadOnlySpan<byte>) The number of matches in a UTF-8 text, allocating nothing.

Count(string)

Source: Regex.Matching.cs

The number of matches in a text.

public int Count(string input)

Parameters

Name Type Description
input string The text.

Returns

int

The number.

Exceptions

Exception Description
RegexMatchTimeoutException A match reached its limit.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Count(ReadOnlySpan<char>)

Source: Regex.Matching.cs

The number of matches in a UTF-16 text, allocating nothing.

public int Count(ReadOnlySpan<char> input)

Parameters

Name Type Description
input ReadOnlySpan<char> The text.

Returns

int

The number.

Exceptions

Exception Description
RegexMatchTimeoutException A match reached its limit.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Count(ReadOnlySpan<byte>)

Source: Regex.Matching.cs

The number of matches in a UTF-8 text, allocating nothing.

public int Count(ReadOnlySpan<byte> utf8)

Parameters

Name Type Description
utf8 ReadOnlySpan<byte> The text.

Returns

int

The number.

Exceptions

Exception Description
RegexMatchTimeoutException A match reached its limit.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests.

Open an issue