Created
December 17, 2014 11:27
-
-
Save javierhonduco/cb0ea120c60c0c8f29de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function string:split(sep) | |
local sep, fields = sep or ":", {} | |
local pattern = string.format("([^%s]+)", sep) | |
self:gsub(pattern, function(c) fields[#fields+1] = c end) | |
return fields | |
end | |
function patterns_hack(to_match, fake_regex, separator) | |
local result | |
for k, v in next, string.split(fake_regex, separator) do | |
result = result or string.match(to_match, v) | |
end | |
return result | |
end | |
to_match = "hola" | |
fake_regex = "(hola)|(guap[ao])" | |
print(patterns_hack(to_match, fake_regex, '|')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment