Jump to content

Tokenize a string: Difference between revisions

(Undo revision 115192 by 86.145.79.157 (talk) revert Haskell entry; new version uses non-standard library and deleted many examples)
Line 1,402:
 
<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}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.