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

4 lines
251 B
Tcl
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
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]]