Module rsre¶
Require: require("rsre")
Index¶
Api reference¶
-
class rsre.Match:
userdata¶ -
start:
integer¶ Get the 1-indexed byte start position of the match (inclusive).
-
stop:
integer¶ Get the 1-indexed byte stop position of the match (exclusive).
-
text:
string¶ Get the matched substring.
-
range(self):
integer,integer¶ Get the start and stop positions of the match.
See also
rsre.Match.start,rsre.Match.stop,rsre.Match.start,rsre.Match.stop,rsre.Match.start,rsre.Match.stop,rsre.Match.start,rsre.Match.stop
-
start:
-
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.
-
get(self, index:
-
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
textwithrep, optionally up tolimittimes.
-
split(self, text:
string, limit?:integer):string[]¶ Split a string at every match, optionally up to
limittimes.
-
staticmethod new(pattern:
-
rsre.escape(text:
string):string¶ Escapes special characters in text with ‘’. Returns a string which, when interpreted as a regex, matches exactly
text.- Parameters:
text (
string) – The string to escape