Tokenize a string: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 6: | Line 6: | ||
'''Interpreter:''' [[Perl]] any 5.X |
'''Interpreter:''' [[Perl]] any 5.X |
||
# in split, between the // goes a regex |
|||
my @words = split(/,/, "Hello,How,Are,You,Today"); |
|||
print join('.', @words); # does not include a trailing period |
|||
Alternate |
|||
my @words = split(/,/, "Hello,How,Are,You,Today"); |
|||
print $_.'.' for (@words); # includes a trailing period |
|||
Or my personal favorite, the one liner |
|||
print join('.', split(/,/, "Hello,How,Are,You,Today")); |
|||
==[[Ruby]]== |
==[[Ruby]]== |