Show / Hide Table of Contents

Method ExtString.RxFindAll(+ 3 overloads)


Overload

Finds all match instances of PCRE regular expression rx.

public static IEnumerable<RXMatch> RxFindAll(this string t, string rx, RXFlags flags = 0, Range? range = null)
Parameters
t  (string)

This string.

rx  (string)

Regular expression. Cannot be null.

flags  (RXFlags)

Options. Default 0. Flag UTF is implicitly added if rx contains non-ASCII characters and there is no flag NEVER_UTF.

range  (Range?)

Start and end offsets in the subject string. If null (default), uses whole string. Examples: i..j (from i to j), i.. (from i to the end), ..j (from 0 to j). The subject part before the start index is not ignored if regular expression starts with a lookbehind assertion or anchor, eg ^ or \b or (?<=...). Instead of ^ you can use \G or flag RXFlags.ANCHORED. More info in PCRE documentation topic pcre2api, chapter "The string to be matched by pcre2_match()". The subject part after the end index is always ignored.

Returns
IEnumerable<RXMatch>

A lazy IEnumerable<RXMatch> that can be used with foreach.

Exceptions
ArgumentOutOfRangeException

Invalid range.

ArgumentException

Invalid regular expression. Or used a PARTIAL_ flag.

AuException

Failed (unlikely).

ArgumentNullException

s is null.

Remarks

More info and examples: regexp.


Overload(next)

Finds all match instances of PCRE regular expression rx. Gets array of RXMatch.

public static bool RxFindAll(this string t, string rx, out RXMatch[] result, RXFlags flags = 0, Range? range = null)
Parameters
t  (string)

This string.

rx  (string)

Regular expression. Cannot be null.

result  (RXMatch[])

Receives all found matches.

flags  (RXFlags)

Options. Default 0. Flag UTF is implicitly added if rx contains non-ASCII characters and there is no flag NEVER_UTF.

range  (Range?)

Start and end offsets in the subject string. If null (default), uses whole string. Examples: i..j (from i to j), i.. (from i to the end), ..j (from 0 to j). The subject part before the start index is not ignored if regular expression starts with a lookbehind assertion or anchor, eg ^ or \b or (?<=...). Instead of ^ you can use \G or flag RXFlags.ANCHORED. More info in PCRE documentation topic pcre2api, chapter "The string to be matched by pcre2_match()". The subject part after the end index is always ignored.

Returns
bool

true if found 1 or more matches.

Exceptions
ArgumentOutOfRangeException

Invalid range.

ArgumentException

Invalid regular expression. Or used a PARTIAL_ flag.

AuException

Failed (unlikely).

ArgumentNullException

s is null.

Remarks

More info and examples: regexp.


Overload(next)

Finds all match instances of PCRE regular expression rx.

public static IEnumerable<string> RxFindAll(this string t, string rx, int group, RXFlags flags = 0, Range? range = null)
Parameters
t  (string)

This string.

rx  (string)

Regular expression. Cannot be null.

group  (int)

Group number (1-based index) of results. If 0 - whole match. See also regexp.GetGroupNumberOf.

flags  (RXFlags)

Options. Default 0. Flag UTF is implicitly added if rx contains non-ASCII characters and there is no flag NEVER_UTF.

range  (Range?)

Start and end offsets in the subject string. If null (default), uses whole string. Examples: i..j (from i to j), i.. (from i to the end), ..j (from 0 to j). The subject part before the start index is not ignored if regular expression starts with a lookbehind assertion or anchor, eg ^ or \b or (?<=...). Instead of ^ you can use \G or flag RXFlags.ANCHORED. More info in PCRE documentation topic pcre2api, chapter "The string to be matched by pcre2_match()". The subject part after the end index is always ignored.

Returns
IEnumerable<string>

A lazy IEnumerable<string> that can be used with foreach.

Exceptions
ArgumentOutOfRangeException

Invalid group or range.

ArgumentException

Invalid regular expression. Or used a PARTIAL_ flag.

AuException

Failed (unlikely).

ArgumentNullException

s is null.

Remarks

More info and examples: regexp.


Overload(top)

Finds all match instances of PCRE regular expression rx. Gets array of strings.

public static bool RxFindAll(this string t, string rx, int group, out string[] result, RXFlags flags = 0, Range? range = null)
Parameters
t  (string)

This string.

rx  (string)

Regular expression. Cannot be null.

group  (int)

Group number (1-based index) of results. If 0 - whole match. See also regexp.GetGroupNumberOf.

result  (string[])

Receives all found matches.

flags  (RXFlags)

Options. Default 0. Flag UTF is implicitly added if rx contains non-ASCII characters and there is no flag NEVER_UTF.

range  (Range?)

Start and end offsets in the subject string. If null (default), uses whole string. Examples: i..j (from i to j), i.. (from i to the end), ..j (from 0 to j). The subject part before the start index is not ignored if regular expression starts with a lookbehind assertion or anchor, eg ^ or \b or (?<=...). Instead of ^ you can use \G or flag RXFlags.ANCHORED. More info in PCRE documentation topic pcre2api, chapter "The string to be matched by pcre2_match()". The subject part after the end index is always ignored.

Returns
bool

true if found 1 or more matches.

Exceptions
ArgumentOutOfRangeException

Invalid group or range.

ArgumentException

Invalid regular expression. Or used a PARTIAL_ flag.

AuException

Failed (unlikely).

ArgumentNullException

s is null.

Remarks

More info and examples: regexp.