Count occurrences of a substring: Difference between revisions

(→‎{{header|Euphoria}}: Euphoria example added)
Line 341:
<pre>3
2
2</pre>
=={{header|Lua}}==
<lang lua>function Count_Substring( s1, s2 )
return select( 2, s1:gsub( s2, "" ) )
end
 
print( Count_Substring( "the three truths", "th" ) )
print( Count_Substring( "ababababab","abab" ) )</lang>
<pre>3
2</pre>
 
Anonymous user