Count occurrences of a substring: Difference between revisions

Content added Content deleted
(/* {{header|Go}})
Line 101: Line 101:
<pre>3
<pre>3
2</pre>
2</pre>

=={{header|Go}}==
Using strings.Count() method:<lang Go>package main
import (
"fmt"
"strings"
)

func main() {
fmt.Println(strings.Count("the three truths", "th")) // says: 3
fmt.Println(strings.Count("ababababab", "abab")) // says: 2
}</lang>


=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==