RosettaCodeData/Task/String-matching/Tcl/string-matching-1.tcl
2023-07-01 13:44:08 -04:00

3 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]]