2024-04-20 22:30:08 +01:00
|
|
|
--!nolint
|
|
|
|
|
|
|
|
local regex = require("@lune/regex")
|
|
|
|
|
|
|
|
local re = regex.new("[0-9]+")
|
2024-06-05 19:18:23 +01:00
|
|
|
assert(tostring(re) == "[0-9]+")
|
2024-04-20 22:30:08 +01:00
|
|
|
assert(typeof(re) == "Regex")
|
|
|
|
|
|
|
|
local mtch = re:find("1337 wow")
|
2024-06-05 19:18:23 +01:00
|
|
|
assert(tostring(mtch) == "1337")
|
2024-04-20 22:30:08 +01:00
|
|
|
assert(typeof(mtch) == "RegexMatch")
|
|
|
|
|
2024-04-20 22:38:06 +01:00
|
|
|
local re2 = regex.new("([0-9]+) ([0-9]+) wow! ([0-9]+) ([0-9]+)")
|
|
|
|
local captures = re2:captures("1337 125600 wow! 1984 0")
|
2024-06-05 19:18:23 +01:00
|
|
|
assert(tostring(captures) == "4")
|
2024-04-20 22:30:08 +01:00
|
|
|
assert(typeof(captures) == "RegexCaptures")
|