Skip to content

Instantly share code, notes, and snippets.

@javierhonduco
Created December 17, 2014 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javierhonduco/cb0ea120c60c0c8f29de to your computer and use it in GitHub Desktop.
Save javierhonduco/cb0ea120c60c0c8f29de to your computer and use it in GitHub Desktop.
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