RosettaCodeData/Task/Regular-expressions/Lua/regular-expressions.lua

10 lines
177 B
Lua

test = "My name is Lua."
pattern = ".*name is (%a*).*"
if test:match(pattern) then
print("Name found.")
end
sub, num_matches = test:gsub(pattern, "Hello, %1!")
print(sub)