Anonymous user
Count occurrences of a substring: Difference between revisions
no edit summary
(→{{header|SNOBOL4}}: Add Ruby.) |
No edit summary |
||
Line 342:
2
2</pre>
=={{header|Liberty BASIC}}==
<lang lb>
print countSubstring( "the three truths", "th")
print countSubstring( "ababababab", "abab")
end
function countSubstring( a$, s$)
c =0
la =len( a$)
ls =len( s$)
for i =1 to la -ls
if mid$( a$, i, ls) =s$ then c =c +1: i =i +ls -1
next i
countSubstring =c
end function
</lang>
=={{header|Lua}}==
<lang lua>function Count_Substring( s1, s2 )
|