Mercurial > repos > tabletprog
comparison samples/stringops.tp @ 152:a6739206a9e3
Add splitOn and partitionOn to string objects
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 09 Aug 2013 20:12:04 -0700 |
parents | 3e9cb69e516d |
children | 38140b7dbe3d |
comparison
equal
deleted
inserted
replaced
151:3e9cb69e516d | 152:a6739206a9e3 |
---|---|
7 print: (string: ("foobarbaz" find: "baz" else: { "not found" })) . "\n" | 7 print: (string: ("foobarbaz" find: "baz" else: { "not found" })) . "\n" |
8 print: (string: ("foobarbaz" find: "qux" else: { "not found" })) . "\n" | 8 print: (string: ("foobarbaz" find: "qux" else: { "not found" })) . "\n" |
9 | 9 |
10 print: ("foobarbaz" from: 3) . "\n" | 10 print: ("foobarbaz" from: 3) . "\n" |
11 print: ("foobarbaz" from: 3 withLength: 3) . "\n" | 11 print: ("foobarbaz" from: 3 withLength: 3) . "\n" |
12 | |
13 foreach: ("foo,bar,baz,qux" splitOn: ",") :idx val { | |
14 print: val . "\n" | |
15 } | |
16 | |
17 res <- "foobarbaz" partitionOn: "bar" | |
18 print: "Before: " . (res before) . "\n" | |
19 print: "After: " . (res after) . "\n" | |
12 } | 20 } |
13 } | 21 } |