Count occurrences of a substring: Difference between revisions
Content deleted Content added
Add NewLISP example. |
|||
Line 531:
=={{header|Lua}}==
<lang lua>function Count_Substring( s1, s2 )
local magic = "[%^%$%(%)%.%[%]%*%+%-%?]"
return select( 2, s1:gsub( s2, "" ) )▼
local percent = function(s)return "%"..s end
▲ return select( 2, s1:gsub( s2:gsub(magic,percent), "" ) )
end
|