This has been asked before at Pattern in lua with anchors not matching however I have a test case that shows that it still doesn't appear to work:
patterns = {
'a@b',
'^a@b',
'a@b.com',
'my-a@b',
'my-a@b.com',
'a@b.com$',
'^this-is-my-a@b.com',
'this-is-my-a@b.com$',
'^this-is-my-a@b.com$',
}
test = "this-is-my-a@b.com"
for _, pattern in ipairs(patterns) do
print(pattern .. ": " .. test .. "\n\tfind: " .. (test:find(pattern) or 'nil') .. "\n\tmatch: " .. (test:match(pattern) or 'nil'))
print(pattern .. ": " .. test .. "\n\tfind: " .. (string.find(test, pattern) or 'nil') .. "\n\tmatch: " .. (string.match(test, pattern) or 'nil'))
end
I did the separate test:find vs string.find(test...) just to be sure there were no shenanigans.
Can someone enlighten me on how I can get my anchored patterns to work?
Aucun commentaire:
Enregistrer un commentaire