String matching: Difference between revisions

Added Swift example
m (→‎TXR Lisp: Drop @(do ...); rename script to cmatch2.tl)
(Added Swift example)
Line 2,689:
val loc = #2 (Substring.base (#2 (Substring.position "ab" (Substring.full "abab")))); (* returns 0 *)
val loc' = #2 (Substring.base (#2 (Substring.position "ab" (Substring.extract ("abab", loc+1, NONE))))); (* returns 2 *)</lang>
 
=={{header|Swift}}==
<lang swift>var str = "Hello, playground"
str.hasPrefix("Hell") //True
str.hasPrefix("hell") //False
 
str.containsString("llo") //True
str.containsString("xxoo") //False
 
str.hasSuffix("playground") //True
str.hasSuffix("world") //False</lang>
 
=={{header|Tcl}}==
Anonymous user