Anonymous user
Multisplit: Difference between revisions
m
clean up to make examples clearer
(add SenseTalk examples) |
m (clean up to make examples clearer) |
||
Line 1,732:
=={{header|SenseTalk}}==
First approach, using line delimiters. Lines are delimited by an array of separator strings, normally [CRLF, LF, CR, lineSeparator(0x2028), paragraphSeparator(0x2029)]. Supplying an alternate set of delimiters lets us split a string by a different (ordered) set of strings
<lang sensetalk>▼
<lang sensetalk>set source to "a!===b=!=c"
set separators to ["==", "!=", "="]
put each line delimited by separators of source</lang>▼
Output:
▲put each line delimited by separators of source
▲<lang sensetalk>(a,,b,,c)</lang>
Second approach, using a pattern. SenseTalk's pattern language lets us define a pattern (a regex) which can then be used to split the string and also to display the actual separators that were found.▼
<lang sensetalk>set source to "a!===b=!=c"
set separatorPattern to <"==" or "!=" or "=">
put source split by separatorPattern
put each occurrence of separatorPattern in source
</lang>
Output:
<lang sensetalk>(a,,b,,c)
(!=,==,=,!=)</lang>
▲Lines are delimited by an array of separator strings, normally [CRLF, LF, CR, lineSeparator(0x2028), paragraphSeparator(0x2029)]. Supplying an alternate set of delimiters lets us split a string by a different (ordered) set of strings.
▲SenseTalk's pattern language lets us define a pattern (a regex) which can then be used to split the string and also to display the actual separators that were found.
=={{header|Sidef}}==
|