Tokenize a string: Difference between revisions
Content added Content deleted
m (→version 1: legitimized the REXX program's 1st statement. -- ~~~~) |
m (→{{header|REXX}}: added needed 1st statement for REXX programs. -- ~~~~) |
||
Line 1,366: | Line 1,366: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
===version 1=== |
===version 1=== |
||
<lang rexx>/*REXX program to seperate a string of comma-delimited words. */ |
<lang rexx>/*REXX program to seperate a string of comma-delimited words, and echo. */ |
||
sss='Hello,How,Are,You,Today' /*words seperated by commas. |
sss='Hello,How,Are,You,Today' /*words seperated by commas (,). */ |
||
say 'input string='sss /* |
say 'input string='sss /*display the original string. */ |
||
⚫ | |||
say |
|||
⚫ | |||
do items=1 until new=='' /*keep going until SSS is empty.*/ |
do items=1 until new=='' /*keep going until SSS is empty. */ |
||
parse var new a.items ',' new /*parse words delinated by comma*/ |
parse var new a.items ',' new /*parse words delinated by comma.*/ |
||
end |
end |
||
say 'Words in the string:' |
say; say 'Words in the string:' /*Display a header for the list. */ |
||
do k=1 for items /*Now, display all the words. */ |
do k=1 for items /*Now, display all the words. */ |
||
say a.k'.' /*append a period to the word. */ |
say a.k'.' /*append a period to the word. */ |
||
end |
end |
||
say 'End-of-list.' /*Display a trailer for the list*/</lang> |
say 'End-of-list.' /*Display a trailer for the list.*/</lang> |
||
'''output''' |
'''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=== |
===version 2=== |
||
<lang rexx> |
<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 /*display the original string. */ |
|||
say |
|||
say 'Words in the string:' |
say; say 'Words in the string:' /*Display a header for the list. */ |
||
do until sss=='' /*keep going until SSS is empty. */ |
do until sss=='' /*keep going until SSS is empty. */ |
||
Line 1,406: | Line 1,406: | ||
say 'End-of-list.' /*Display a trailer for the list.*/</lang> |
say 'End-of-list.' /*Display a trailer for the list.*/</lang> |
||
'''output''' is identical to Version 1. |
|||
<br> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |