Tokenize a string: Difference between revisions
Content added Content deleted
(Undo revision 115192 by 86.145.79.157 (talk) revert Haskell entry; new version uses non-standard library and deleted many examples) |
(→{{header|TXR}}: Added) |
||
Line 1,402: | Line 1,402: | ||
<lang bash>echo 'Hello,How,Are,You,Today' | tr ',' '.'</lang> |
<lang bash>echo 'Hello,How,Are,You,Today' | tr ',' '.'</lang> |
||
=={{header|TXR}}== |
|||
{{works with|TXR|git head}} |
|||
Collecting tokens which consist of non-empty |
|||
sequences of non-commas. |
|||
<lang txr>@(next :list "Hello,How,Are,You,Today") |
|||
@(coll)@{token /[^,]+/}@(end) |
|||
@(output) |
|||
@(rep)@token.@(last)@token@(end) |
|||
@(end)</lang> |
|||
Different approach. Collect tokens, each of |
|||
which is a piece of text which either terminates |
|||
before a comma, or else extends to the end of the line. |
|||
<lang txr>@(next :list "Hello,How,Are,You,Today") |
|||
@(coll)@(maybe)@token,@(or)@token@(end)@(end) |
|||
@(output) |
|||
@(rep)@token.@(last)@token@(end) |
|||
@(end)</lang> |
|||
=={{header|TUSCRIPT}}== |
=={{header|TUSCRIPT}}== |