RosettaCodeData/Task/String-matching/Tcl/string-matching-1.tcl

4 lines
251 B
Tcl

set isPrefix [string equal -length [string length $needle] $haystack $needle]
set isContained [expr {[string first $needle $haystack] >= 0}]
set isSuffix [string equal $needle [string range $haystack end-[expr {[string length $needle]-1}] end]]