Module rsre

Require: require("rsre")

Index

Api reference

class rsre.Match: userdata
start(self): integer

Get the 1-indexed start position of the match (inclusive).

stop(self): integer

Get the 1-indexed stop position of the match (exclusive).

range(self): integer, integer

Get the start and stop positions of the match.

as_str(self): string

Get the matched substring.

class rsre.Captures: userdata
get(self, index: integer): rsre.Match

Get the match at the provided index.

name(self, name: string): rsre.Match

Get match with the provided name.

len(self): integer

Get the total number of matches.

class rsre.Regex: userdata
staticmethod new(pattern: string): rsre.Regex

Compile a new regex.

match(self, hay: string): boolean

Test if the regex matches the provided string.

find(self, hay: string, pos?: integer): rsre.Match

Find the first, leftmost match after pos.

captures(self, hay: string, pos?: integer): rsre.Captures

Find the first, leftmost captures after pos.

replace(self, text: string, rep: string, limit?: integer): string

Replace matches in text with rep, optionally up to limit times.

split(self, text: string, limit?: integer): string[]

Split a string at every match, optionally up to limit times.

as_str(self): string

The original regex as a string.