Tokenize a string: Difference between revisions

m
→‎{{header|REXX}}: added needed 1st statement for REXX programs. -- ~~~~
m (→‎version 1: legitimized the REXX program's 1st statement. -- ~~~~)
m (→‎{{header|REXX}}: added needed 1st statement for REXX programs. -- ~~~~)
Line 1,366:
=={{header|REXX}}==
===version 1===
<lang rexx>/*REXX program to seperate a string of comma-delimited words, and echo. */
sss='Hello,How,Are,You,Today' /*words seperated by commas (,). */
say 'input string='sss /*echodisplay the stringoriginal to consolestring. */
new=sss /*make a copy of the string. */
say
new=sss /*make a copy of the string. */
 
do items=1 until new=='' /*keep going until SSS is empty. */
parse var new a.items ',' new /*parse words delinated by comma.*/
end
 
say; say 'Words in the string:' /*Display a header for the list. */
 
do k=1 for items /*Now, display all the words. */
say a.k'.' /*append a period to the word. */
end
 
say 'End-of-list.' /*Display a trailer for the list.*/</lang>
'''output'''
<pre style="height:30ex;overflow:scroll">
input string=Hello,How,Are,You,Today
Words in the string:
Hello.
How.
Are.
You.
Today.
End-of-list.
</pre>
 
===version 2===
<lang rexx>sss='Hello,How,Are,You,Today'/*REXX program to seperate a string of comma-delimited /*words, seperatedand by commasecho. */
say 'input stringsss='sss Hello,How,Are,You,Today' /*echowords theseperated stringby tocommas console(,). */
say 'input string='sss /*display the original string. */
say
say; say 'Words in the string:' /*Display a header for the list. */
 
do until sss=='' /*keep going until SSS is empty. */
Line 1,406:
 
say 'End-of-list.' /*Display a trailer for the list.*/</lang>
Output'''output''' is identical to Version 1.
<br>
 
=={{header|Ruby}}==