Jump to content

Tokenize a string: Difference between revisions

m
{{out}}
m ({{out}})
Line 1:
{{task|String manipulation}}
Separate the string "Hello,How,Are,You,Today" by commas into an array (or list) so that each element of it stores a different word. Display the words to the 'user', in the simplest manner possible, separated by a period. To simplify, you may display a trailing period.
Display the words to the 'user', in the simplest manner possible, separated by a period.
To simplify, you may display a trailing period.
 
'''''Related tasks:'''''
Line 38 ⟶ 40:
(print-with (rest strs) delim))))</lang>
 
{{out}}
Output:
<pre>&gt; (print-with (split-str "Hello,How,Are,You,Today" #\,) #\.)
Hello.How.Are.You.Today.</pre>
Line 120 ⟶ 122:
printf(($g"."$, char split(beetles, ", "),$l$))
)</lang>
{{out}}
Output:
<pre>
John Lennon.Paul McCartney.George Harrison.Ringo Starr.
John.Lennon..Paul.McCartney..George.Harrison..Ringo.Starr.
</pre>
 
=={{header|AutoHotkey}}==
Line 786 ⟶ 790:
end</lang>
 
{{out}}
Output:
<pre>
->ss
Hello.How.Are.You.
->
</pre>
 
=={{header|Io}}==
Line 927 ⟶ 933:
:- end_object.
</lang>
{{out}}
Output:
<pre>
<lang text>
| ?- spliting::convert('Hello,How,Are,You,Today', Converted).
Converted = 'Hello.How.Are.You.Today'
yes
</langpre>
 
=={{header|Lua}}==
Line 983 ⟶ 989:
show</lang>
 
{{out}}
Output:
<pre>
Hello.How.Are.You.Today.
</pre>
 
 
=={{header|Mathematica}}==
Line 1,005 ⟶ 1,014:
end</lang>
 
{{out}}
Output:
<lang MATLABpre>>> tokenizeString('Hello,How,Are,You,Today',',')
Hello.How.Are.You.Today</langpre>
 
=={{header|Maxima}}==
Line 1,092 ⟶ 1,101:
PBNZ t,2B % UNTIL EOB(uffer)
TRAP 0,Halt,0</lang>
{{out}}
Output:
<pre>
~/MIX/MMIX/Progs> mmix tokenizing
Hello
Line 1,099 ⟶ 1,109:
You
Today
</pre>
 
=={{header|Modula-3}}==
Line 1,278 ⟶ 1,289:
tokenizeString( "Hello,How,Are,You,Today" )
VIEW-AS ALERT-BOX.</lang>
{{out}}
Output:
<pre>
---------------------------
Message
Line 1,286 ⟶ 1,298:
OK
---------------------------
</pre>
 
=={{header|Oz}}==
Line 1,515 ⟶ 1,528:
string_to_list(ABack,Backtogether),
writeln(ABack).</lang>
{{out}}
Output:
<pre>
?- start.
Hello.How.Are.You.Today
</pre>
 
=={{header|Python}}==
Line 1,555 ⟶ 1,570:
print ["Dotted: " dotted]</lang>
 
{{out}}
Output:
<pre>
Original: Hello,How,Are,You,Today
Dotted: Hello.How.Are.You.Today.
</pre>
 
=={{header|Retro}}==
Line 1,603 ⟶ 1,620:
say 'End-of-list.' /*display a trailer for the list.*/
/*stick a fork in it, we're done.*/</lang>
{{out}}
'''output'''
<pre>
input string = Hello,How,Are,You,Today
Line 1,641 ⟶ 1,658:
end</lang>
 
{{out}}
Output:
<pre>
Hello.How.Are.You.Today.
</pre>
 
=={{header|Ruby}}==
Line 1,711 ⟶ 1,730:
end</lang>
 
{{out}}
Output:
<pre>
Hello.How.Are.You.Today
</pre>
 
=={{header|Standard ML}}==
Line 1,888 ⟶ 1,909:
 
main = mat`. token_list</lang>
{{out}}
Output:
<pre>
'Hello.How.Are.You.Today'
</pre>
 
=={{header|Vala}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.