Multisplit: Difference between revisions
Content added Content deleted
(add SenseTalk examples) |
m (clean up to make examples clearer) |
||
Line 1,732: | Line 1,732: | ||
=={{header|SenseTalk}}== |
=={{header|SenseTalk}}== |
||
⚫ | |||
⚫ | |||
set source to "a!===b=!=c" |
<lang sensetalk>set source to "a!===b=!=c" |
||
set separators to ["==", "!=", "="] |
set separators to ["==", "!=", "="] |
||
⚫ | |||
// first approach, using line delimiters |
|||
Output: |
|||
⚫ | |||
⚫ | |||
⚫ | |||
// second approach, using a pattern |
|||
set source to "a!===b=!=c" |
<lang sensetalk>set source to "a!===b=!=c" |
||
set separatorPattern to <"==" or "!=" or "="> |
set separatorPattern to <"==" or "!=" or "="> |
||
put source split by separatorPattern |
put source split by separatorPattern |
||
// and show the separators that were found, for extra credit: |
|||
put each occurrence of separatorPattern in source |
put each occurrence of separatorPattern in source |
||
</lang> |
</lang> |
||
Output: |
Output: |
||
<lang sensetalk>(a,,b,,c) |
<lang sensetalk>(a,,b,,c) |
||
(a,,b,,c) |
|||
(!=,==,=,!=)</lang> |
(!=,==,=,!=)</lang> |
||
Explanation: |
|||
⚫ | |||
⚫ | |||
=={{header|Sidef}}== |
=={{header|Sidef}}== |