Tokenize a string: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
 
No edit summary
Line 1: Line 1:
{{task}}
{{task}}
Separate the string "Hello,How,Are,You,Today" by commas into an array so that each index of the array 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.
Separate the string "Hello,How,Are,You,Today" by commas into an array so that each index of the array 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.

==[[Perl]]==
[[Category:Perl]]
'''Interpreter:''' [[Perl]] any 5.X




==[[Ruby]]==
==[[Ruby]]==

Revision as of 16:35, 2 February 2007

Task
Tokenize a string
You are encouraged to solve this task according to the task description, using any language you may know.

Separate the string "Hello,How,Are,You,Today" by commas into an array so that each index of the array 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.

Perl

Interpreter: Perl any 5.X


Ruby

    string = "Hello,How,Are,You,Today".split(',')
    string.each do |w|
         print "#{w}."
    end