nthMatch method

RegExpMatch? nthMatch(
  1. int index,
  2. String input,
  3. {bool reverse = false}
)

Searches input for the match found at index. Returns null if one isn't found.

index must not be null and must be >= 0. index will be counted in the order matches are found. (In the order their delimiters are closed. If an index of 3 is supplied, the 3rd match will be returned, however if reverse is true, the 3rd from last match will be returned.)

input must not be null.

If reverse is true, input's delimited blocks of text will be parsed in reverse order. If looking for a match towards the end of the string, finding it in reverse order is more efficient. reverse must not be null.

Implementation

RegExpMatch? nthMatch(
  int index,
  String input, {
  bool reverse = false,
}) {
  assert(index >= 0);
  return getMatches(input, start: index, stop: index, reverse: false)?.first;
}