Count occurrences of a substring: Difference between revisions

m
→‎{{header|Tcl}}: fix blurb text
(→‎{{header|Tcl}}: Demonstrate the lack of re-metachar problems)
m (→‎{{header|Tcl}}: fix blurb text)
Line 28:
 
=={{header|Tcl}}==
The regular expression engine is ideal for matching this task, especially as the <tt>***=</tt> prefix makes it interpret the rest of the argument as a literal string to match:
<lang tcl>proc countSubstrings {haystack needle} {
regexp -all ***=$needle $haystack
Anonymous user