MatchResult

Methods
4
Fields
None

Getting one

Pattern.compile(…):matcher(…):toMatchResult()

Methods

MethodReturnsDescription
group()string?(MatchResult) -> string?: The matched text, or nil when the groups were forgotten (usePattern). Raises IllegalStateException with no…
group(number)string?
start()number(MatchResult) -> number: Where the match starts (a UTF-16 index).
start(number)number
end_()number(MatchResult) -> number: end(), spelled end_ because Luau reserves end: where the match ends (exclusive).
end_(number)number
groupCount()numberHow many capturing groups the pattern has.

Returned by

MethodReturnsDescription
Matcher.matchResults{MatchResult}The remaining results: every match left, as a 1-based array of MatchResult snapshots. It is eager: it finds every match now and leaves th…
Matcher.toMatchResultMatchResultA snapshot of the current match: a MatchResult that shares the text and does not move.

Method details

group

group: ((MatchResult) -> string?) & ((MatchResult, number) -> string?)

(MatchResult) -> string?: The matched text, or nil when the groups were forgotten (usePattern). Raises IllegalStateException with no match.

(MatchResult, number) -> string?: Group group's text, or nil when it did not take part (0 is the whole match).

start

start: ((MatchResult) -> number) & ((MatchResult, number) -> number)

(MatchResult) -> number: Where the match starts (a UTF-16 index).

(MatchResult, number) -> number: Where group group starts, or -1.

end_

end_: ((MatchResult) -> number) & ((MatchResult, number) -> number)

(MatchResult) -> number: end(), spelled end_ because Luau reserves end: where the match ends (exclusive).

(MatchResult, number) -> number: end(group), spelled end_ because Luau reserves end: where group group ends, or -1.

Luau reserves end, so this member is spelled end_; it behaves exactly as end.