Count occurrences of a substring: Difference between revisions

Content deleted Content added
m →‎{{header|Groovy}}: corrected operator name
Line 281:
2</pre>
=={{header|Groovy}}==
Solution, uses the Groovy "matchfind" operator (=~), and the Groovy-extended Matcher property "count":
<lang groovy>println (('the three truths' =~ /th/).count)
println (('ababababab' =~ /abab/).count)