Anonymous user
String matching: Difference between revisions
m
→{{header|Tcl}}: Explanatory notes
(→Tcl: Added implementation) |
m (→{{header|Tcl}}: Explanatory notes) |
||
Line 93:
=={{header|Tcl}}==
In this code, we are looking in various ways for the string in the variable <tt>needle</tt> in the string in the variable <tt>haystack</tt>.
<lang tcl>set isPrefix [string equal -length [string length $needle] $haystack $needle]
set isContained [expr {[string first $needle $haystack] >= 0}]
|