counting number of string occurrences
snippet in lua

counting number of string occurrences

user8425

local _, count = string.gsub(argv, " %-%-", "")
print(count)

counting number of string occurrences

user1087

function count(base, pattern)
    return select(2, string.gsub(base, pattern, ""))
end

print(count('Hello World', 'l'))