Tokenize a string: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(45 intermediate revisions by 27 users not shown)
Line 15: Line 15:
{{trans|Python}}
{{trans|Python}}


<lang 11l>V text = ‘Hello,How,Are,You,Today’
<syntaxhighlight lang="11l">V text = ‘Hello,How,Are,You,Today’
V tokens = text.split(‘,’)
V tokens = text.split(‘,’)
print(tokens.join(‘.’))</lang>
print(tokens.join(‘.’))</syntaxhighlight>


{{out}}
{{out}}
Line 25: Line 25:


=={{header|360 Assembly}}==
=={{header|360 Assembly}}==
<lang 360asm>* Tokenize a string - 08/06/2018
<syntaxhighlight lang="360asm">* Tokenize a string - 08/06/2018
TOKSTR CSECT
TOKSTR CSECT
USING TOKSTR,R13 base register
USING TOKSTR,R13 base register
Line 107: Line 107:
PG DC CL80' ' buffer
PG DC CL80' ' buffer
YREGS
YREGS
END TOKSTR</lang>
END TOKSTR</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 114: Line 114:


=={{header|8080 Assembly}}==
=={{header|8080 Assembly}}==
<lang 8080asm>puts: equ 9
<syntaxhighlight lang="8080asm">puts: equ 9
org 100h
org 100h
jmp demo
jmp demo
Line 161: Line 161:
period: db '. $'
period: db '. $'
hello: db 'Hello,How,Are,You,Today$'
hello: db 'Hello,How,Are,You,Today$'
parts: equ $</lang>
parts: equ $</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello. How. Are. You. Today.</pre>
<pre>Hello. How. Are. You. Today.</pre>
=={{header|8086 Assembly}}==
=={{header|8086 Assembly}}==
<lang asm> cpu 8086
<syntaxhighlight lang="asm"> cpu 8086
org 100h
org 100h
section .text
section .text
Line 203: Line 203:
hello: db 'Hello,How,Are,You,Today$'
hello: db 'Hello,How,Are,You,Today$'
section .bss
section .bss
parts: resw 10</lang>
parts: resw 10</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello. How. Are. You. Today. </pre>
<pre>Hello. How. Are. You. Today. </pre>
Line 209: Line 209:
=={{header|AArch64 Assembly}}==
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
<syntaxhighlight lang="aarch64 assembly">
<lang AArch64 Assembly>
/* ARM assembly AARCH64 Raspberry PI 3B */
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program strTokenize64.s */
/* program strTokenize64.s */
Line 349: Line 349:
/* for this file see task include a file in language AArch64 assembly */
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
.include "../includeARM64.inc"
</syntaxhighlight>
</lang>
{{Output}}
{{Output}}
<pre>
<pre>
Line 361: Line 361:


=={{header|ACL2}}==
=={{header|ACL2}}==
<lang lisp>(defun split-at (xs delim)
<syntaxhighlight lang="lisp">(defun split-at (xs delim)
(if (or (endp xs) (eql (first xs) delim))
(if (or (endp xs) (eql (first xs) delim))
(mv nil (rest xs))
(mv nil (rest xs))
Line 389: Line 389:
(progn$ (cw (first strs))
(progn$ (cw (first strs))
(cw (coerce (list delim) 'string))
(cw (coerce (list delim) 'string))
(print-with (rest strs) delim))))</lang>
(print-with (rest strs) delim))))</syntaxhighlight>


{{out}}
{{out}}
<pre>&gt; (print-with (split-str "Hello,How,Are,You,Today" #\,) #\.)
<pre>&gt; (print-with (split-str "Hello,How,Are,You,Today" #\,) #\.)
Hello.How.Are.You.Today.</pre>
Hello.How.Are.You.Today.</pre>

=={{header|Action!}}==
The user must type in the monitor the following command after compilation and before running the program!<pre>SET EndProg=*</pre>
{{libheader|Action! Tool Kit}}
<syntaxhighlight lang="action!">CARD EndProg ;required for ALLOCATE.ACT

INCLUDE "D2:ALLOCATE.ACT" ;from the Action! Tool Kit. You must type 'SET EndProg=*' from the monitor after compiling, but before running this program!

DEFINE PTR="CARD"

BYTE FUNC Split(CHAR ARRAY s CHAR c PTR ARRAY items)
BYTE i,count,start,len
CHAR ARRAY item

IF s(0)=0 THEN RETURN (0) FI

i=1 count=0
WHILE i<s(0)
DO
start=i
WHILE i<=s(0) AND s(i)#c
DO
i==+1
OD
len=i-start
item=Alloc(len+1)
SCopyS(item,s,start,i-1)
items(count)=item
count==+1
i==+1
OD
RETURN (count)

PROC Join(PTR ARRAY items BYTE count CHAR c CHAR ARRAY s)
BYTE i,pos
CHAR POINTER srcPtr,dstPtr
CHAR ARRAY item

s(0)=0
IF count=0 THEN RETURN FI

pos=1
FOR i=0 TO count-1
DO
item=items(i)
srcPtr=item+1
dstPtr=s+pos
MoveBlock(dstPtr,srcPtr,item(0))
pos==+item(0)
IF i<count-1 THEN
s(pos)='.
pos==+1
FI
OD
s(0)=pos-1
RETURN

PROC Clear(PTR ARRAY items BYTE POINTER count)
BYTE i
CHAR ARRAY item

IF count^=0 THEN RETURN FI

FOR i=0 TO count^-1
DO
item=items(i)
Free(item,item(0)+1)
OD
count^=0
RETURN

PROC Main()
CHAR ARRAY s="Hello,How,Are,You,Today"
CHAR ARRAY r(256)
PTR ARRAY items(100)
BYTE i,count

Put(125) PutE() ;clear screen
AllocInit(0)
count=Split(s,',,items)
Join(items,count,'.,r)

PrintF("Input:%E""%S""%E%E",s)
PrintE("Split:")
FOR i=0 TO count-1
DO
PrintF("""%S""",items(i))
IF i<count-1 THEN
Print(", ")
ELSE
PutE() PutE()
FI
OD
PrintF("Join:%E""%S""%E",r)
Clear(items,@count)
RETURN</syntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Tokenize_a_string.png Screenshot from Atari 8-bit computer]
<pre>
Input:
"Hello,How,Are,You,Today"

Split:
"Hello", "How", "Are", "You", "Today"

Join:
"Hello.How.Are.You.Today"
</pre>


=={{header|ActionScript}}==
=={{header|ActionScript}}==
<lang actionscript>var hello:String = "Hello,How,Are,You,Today";
<syntaxhighlight lang="actionscript">var hello:String = "Hello,How,Are,You,Today";
var tokens:Array = hello.split(",");
var tokens:Array = hello.split(",");
trace(tokens.join("."));
trace(tokens.join("."));


// Or as a one-liner
// Or as a one-liner
trace("Hello,How,Are,You,Today".split(",").join("."));</lang>
trace("Hello,How,Are,You,Today".split(",").join("."));</syntaxhighlight>


=={{header|Ada}}==
=={{header|Ada}}==
<lang ada>with Ada.Text_IO, Ada.Containers.Indefinite_Vectors, Ada.Strings.Fixed, Ada.Strings.Maps;
<syntaxhighlight lang="ada">with Ada.Text_IO, Ada.Containers.Indefinite_Vectors, Ada.Strings.Fixed, Ada.Strings.Maps;
use Ada.Text_IO, Ada.Containers, Ada.Strings, Ada.Strings.Fixed, Ada.Strings.Maps;
use Ada.Text_IO, Ada.Containers, Ada.Strings, Ada.Strings.Fixed, Ada.Strings.Maps;


Line 424: Line 534:
Put (S & ".");
Put (S & ".");
end loop;
end loop;
end Tokenize;</lang>
end Tokenize;</syntaxhighlight>


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
<lang algol68>main:(
<syntaxhighlight lang="algol68">main:(


OP +:= = (REF FLEX[]STRING in out, STRING item)VOID:(
OP +:= = (REF FLEX[]STRING in out, STRING item)VOID:(
Line 475: Line 585:
printf(($g"."$, string split(beetles, ", "),$l$));
printf(($g"."$, string split(beetles, ", "),$l$));
printf(($g"."$, char split(beetles, ", "),$l$))
printf(($g"."$, char split(beetles, ", "),$l$))
)</lang>
)</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
John Lennon.Paul McCartney.George Harrison.Ringo Starr.
John Lennon.Paul McCartney.George Harrison.Ringo Starr.
John.Lennon..Paul.McCartney..George.Harrison..Ringo.Starr.
John.Lennon..Paul.McCartney..George.Harrison..Ringo.Starr.
</pre>

=={{header|Amazing Hopper}}==

Hopper provides instructions for separating and modifying tokens from a string.
Let "s" be a string; "n" token number:

1) {n}, $(s) ==> gets token "n" from string "s".

2) {"word", n} $$(s) ==> replace token "n" of "s", with "word".

Note: the "splitnumber" macro cannot separate a number converted to a string by the "XTOSTR" function, because this function "rounds" the number to the decimal position by default.

<syntaxhighlight lang="hopper">
#include <hopper.h>

#proto splitdate(_DATETIME_)
#proto splitnumber(_N_)
#proto split(_S_,_T_)

main:
s="this string will be separated into parts with space token separator"
aS=0,let( aS :=_split(s," "))
{","}toksep // set a new token separator
{"String: ",s}
{"\nArray:\n",aS},
{"\nSize="}size(aS),println // "size" return an array: {dims,#rows,#cols,#pages}
{"\nOriginal number: ",-125.489922},println
w=0,let(w:=_split number(-125.489922) )
{"Integer part: "}[1]get(w) // get first element from array "w"
{"\nDecimal part: "}[2]get(w),println // get second element from array "w"
{"\nDate by DATENOW(TODAY) macro: "},print
dt=0, let( dt :=_splitdate(datenow(TODAY);!puts)) // "!" keep first element from stack
{"\nDate: "}[1]get(dt)
{"\nTime: "}[2]get(dt),println

exit(0)

.locals
splitdate(_DATETIME_)
_SEP_=0,gettoksep,mov(_SEP_) // "gettoksep" return actual token separator
{","}toksep, // set a new token separator
_NEWARRAY_={}
{1},$( _DATETIME_ ),
{2},$( _DATETIME_ ),pushall(_NEWARRAY_)
{_SEP_}toksep // restore ols token separator
{_NEWARRAY_}
back

splitnumber(_X_)
part_int=0,part_dec=0,
{_X_},!trunc,mov(part_int),
minus(part_int), !sign,mul
xtostr,mov(part_dec), part_dec+=2, // "part_dec+=2", delete "0." from "part_dec"
{part_dec}xtonum,mov(part_dec)
_NEWARRAY_={},{part_int,part_dec},pushall(_NEWARRAY_)
{_NEWARRAY_}
back

split(_S_,_T_)
_NEWARRAY_={},_VAR1_=0,_SEP_=0,gettoksep,mov(_SEP_)
{_T_}toksep,totaltoken(_S_),
mov(_VAR1_), // for total tokens
_VAR2_=1, // for real position of tokens into the string
___SPLIT_ITER:
{_VAR2_}$( _S_ ),push(_NEWARRAY_)
++_VAR2_,--_VAR1_
{ _VAR1_ },jnz(___SPLIT_ITER) // jump to "___SPLIT_ITER" if "_VAR1_" is not zero.
clear(_VAR2_),clear(_VAR1_)
{_SEP_}toksep
{_NEWARRAY_}
back

</syntaxhighlight>
{{Out}}
<pre>Output:

String: this string will be separated into parts with space token separator
Array:
this,string,will,be,separated,into,parts,with,space,token,separator
Size=1,11

Original number: -125.49
Integer part: -125
Decimal part: 489922

Date by DATENOW(TODAY) macro: 22/11/2021,18:41:20:13
Date: 22/11/2021
Time: 18:41:20:13

</pre>
</pre>


=={{header|APL}}==
=={{header|APL}}==
<lang APL> '.',⍨¨ ','(≠⊆⊢)'abc,123,X' ⍝ [1] Do the split: ','(≠⊆⊢)'abc,123,X'; [2] append the periods: '.',⍨¨
<syntaxhighlight lang="apl"> '.',⍨¨ ','(≠⊆⊢)'abc,123,X' ⍝ [1] Do the split: ','(≠⊆⊢)'abc,123,X'; [2] append the periods: '.',⍨¨
abc. 123. X. ⍝ 3 strings (char vectors), each with a period at the end.
abc. 123. X. ⍝ 3 strings (char vectors), each with a period at the end.
</syntaxhighlight>
</lang>


=={{header|AppleScript}}==
=={{header|AppleScript}}==


<lang applescript>on run
<syntaxhighlight lang="applescript">on run
intercalate(".", splitOn(",", "Hello,How,Are,You,Today"))
intercalate(".", splitOn(",", "Hello,How,Are,You,Today"))
end run
end run
Line 508: Line 713:
set my text item delimiters to dlm
set my text item delimiters to dlm
return strJoined
return strJoined
end intercalate</lang>
end intercalate</syntaxhighlight>
{{Out}}
{{Out}}
<pre>Hello.How.Are.You.Today</pre>
<pre>Hello.How.Are.You.Today</pre>
Line 514: Line 719:
Or,
Or,


<lang AppleScript>set my text item delimiters to ","
<syntaxhighlight lang="applescript">set my text item delimiters to ","
set tokens to the text items of "Hello,How,Are,You,Today"
set tokens to the text items of "Hello,How,Are,You,Today"


set my text item delimiters to "."
set my text item delimiters to "."
log tokens as text</lang>
log tokens as text</syntaxhighlight>


{{Out}}
{{Out}}
Line 526: Line 731:
=={{header|ARM Assembly}}==
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
{{works with|as|Raspberry Pi}}
<syntaxhighlight lang="arm assembly">
<lang ARM Assembly>


/* ARM assembly Raspberry PI */
/* ARM assembly Raspberry PI */
Line 690: Line 895:
bx lr
bx lr
</syntaxhighlight>
</lang>


=={{header|Arturo}}==
=={{header|Arturo}}==
<lang rebol>str: "Hello,How,Are,You,Today"
<syntaxhighlight lang="rebol">str: "Hello,How,Are,You,Today"


print join.with:"." split.by:"," str</lang>
print join.with:"." split.by:"," str</syntaxhighlight>


{{out}}
{{out}}
Line 702: Line 907:


=={{header|Astro}}==
=={{header|Astro}}==
<lang python>let text = 'Hello,How,Are,You,Today'
<syntaxhighlight lang="python">let text = 'Hello,How,Are,You,Today'
let tokens = text.split(||,||)
let tokens = text.split(||,||)
print tokens.join(with: '.')</lang>
print tokens.join(with: '.')</syntaxhighlight>


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
<lang AutoHotkey>string := "Hello,How,Are,You,Today"
<syntaxhighlight lang="autohotkey">string := "Hello,How,Are,You,Today"
stringsplit, string, string, `,
stringsplit, string, string, `,
loop, % string0
loop, % string0
{
{
msgbox % string%A_Index%
msgbox % string%A_Index%
}</lang>
}</syntaxhighlight>


=={{header|AWK}}==
=={{header|AWK}}==


<lang awk>BEGIN {
<syntaxhighlight lang="awk">BEGIN {
s = "Hello,How,Are,You,Today"
s = "Hello,How,Are,You,Today"
split(s, arr, ",")
split(s, arr, ",")
Line 723: Line 928:
}
}
print
print
}</lang>
}</syntaxhighlight>


A more ''idiomatic'' way for AWK is
A more ''idiomatic'' way for AWK is


<lang awk>BEGIN { FS = "," }
<syntaxhighlight lang="awk">BEGIN { FS = "," }
{
{
for(i=1; i <= NF; i++) printf $i ".";
for(i=1; i <= NF; i++) printf $i ".";
print ""
print ""
}</lang>
}</syntaxhighlight>


which "tokenize" each line of input and this is achieved by using "," as field separator
which "tokenize" each line of input and this is achieved by using "," as field separator
Line 737: Line 942:
=={{header|BASIC}}==
=={{header|BASIC}}==
==={{header|Applesoft BASIC}}===
==={{header|Applesoft BASIC}}===
<lang ApplesoftBasic>100 T$ = "HELLO,HOW,ARE,YOU,TODAY"
<syntaxhighlight lang="applesoftbasic">100 T$ = "HELLO,HOW,ARE,YOU,TODAY"
110 GOSUB 200"TOKENIZE
110 GOSUB 200"TOKENIZE
120 FOR I = 1 TO N
120 FOR I = 1 TO N
Line 756: Line 961:
290 A$(N) = A$(N) + C$
290 A$(N) = A$(N) + C$
300 NEXT TI
300 NEXT TI
310 RETURN</lang>
310 RETURN</syntaxhighlight>


==={{header|BaCon}}===
==={{header|BaCon}}===
BaCon includes extensive support for ''delimited strings''.
BaCon includes extensive support for ''delimited strings''.
<lang bacon>OPTION BASE 1
<syntaxhighlight lang="bacon">OPTION BASE 1


string$ = "Hello,How,Are,You,Today"
string$ = "Hello,How,Are,You,Today"
Line 771: Line 976:


' Or simply replace the delimiter
' Or simply replace the delimiter
PRINT DELIM$(string$, ",", ".")</lang>
PRINT DELIM$(string$, ",", ".")</syntaxhighlight>


{{out}}
{{out}}
Line 777: Line 982:
Hello.How.Are.You.Today
Hello.How.Are.You.Today
Hello.How.Are.You.Today</pre>
Hello.How.Are.You.Today</pre>

==={{header|BASIC256}}===
<syntaxhighlight lang="basic256">instring$ = "Hello,How,Are,You,Today"

tokens$ = explode(instring$,",")
for i = 0 to tokens$[?]-1
print tokens$[i]; ".";
next i
end</syntaxhighlight>



==={{header|BBC BASIC}}===
==={{header|BBC BASIC}}===
{{works with|BBC BASIC for Windows}}
{{works with|BBC BASIC for Windows}}
<lang bbcbasic> INSTALL @lib$+"STRINGLIB"
<syntaxhighlight lang="bbcbasic"> INSTALL @lib$+"STRINGLIB"
text$ = "Hello,How,Are,You,Today"
text$ = "Hello,How,Are,You,Today"
Line 787: Line 1,002:
PRINT array$(i%) "." ;
PRINT array$(i%) "." ;
NEXT
NEXT
PRINT</lang>
PRINT</syntaxhighlight>

==={{header|Chipmunk Basic}}===
Solutions [[#Applesoft BASIC|Applesoft BASIC]] and [[#Commodore BASIC|Commodore BASIC]] work without changes.


==={{header|Commodore BASIC}}===
==={{header|Commodore BASIC}}===
Based on the AppleSoft BASIC version.
Based on the AppleSoft BASIC version.
<lang commodorebasic>
<syntaxhighlight lang="commodorebasic">10 REM TOKENIZE A STRING ... ROSETTACODE.ORG
10 REM TOKENIZE A STRING ... ROSETTACODE.ORG
20 T$ = "HELLO,HOW,ARE,YOU,TODAY"
20 T$ = "HELLO,HOW,ARE,YOU,TODAY"
30 GOSUB 200, TOKENIZE
30 GOSUB 200, TOKENIZE
Line 808: Line 1,025:
260 N = N + 1
260 N = N + 1
270 NEXT L
270 NEXT L
280 RETURN
280 RETURN</syntaxhighlight>

</lang>
==={{header|FreeBASIC}}===
==={{header|FreeBASIC}}===
<lang freebasic>sub tokenize( instring as string, tokens() as string, sep as string )
<syntaxhighlight lang="freebasic">sub tokenize( instring as string, tokens() as string, sep as string )
redim tokens(0 to 0) as string
redim tokens(0 to 0) as string
dim as string*1 ch
dim as string*1 ch
Line 832: Line 1,049:
for i as uinteger = 0 to ubound(tokens)
for i as uinteger = 0 to ubound(tokens)
print tokens(i);".";
print tokens(i);".";
next i</lang>
next i</syntaxhighlight>


==={{header|Liberty BASIC}}===
==={{header|Liberty BASIC}}===
<lang lb>'Note that Liberty Basic's array usage can reach element #10 before having to DIM the array
<syntaxhighlight lang="lb">'Note that Liberty Basic's array usage can reach element #10 before having to DIM the array
For i = 0 To 4
For i = 0 To 4
array$(i) = Word$("Hello,How,Are,You,Today", (i + 1), ",")
array$(i) = Word$("Hello,How,Are,You,Today", (i + 1), ",")
Line 841: Line 1,058:
Next i
Next i


Print Left$(array$, (Len(array$) - 1))</lang>
Print Left$(array$, (Len(array$) - 1))</syntaxhighlight>


==={{header|PowerBASIC}}===
==={{header|MSX Basic}}===
The [[#Commodore BASIC|Commodore BASIC]] solution works without any changes.


==={{header|PowerBASIC}}===
PowerBASIC has a few keywords that make parsing strings trivial: <code>PARSE</code>, <code>PARSE$</code>, and <code>PARSECOUNT</code>. (<code>PARSE$</code>, not shown here, is for extracting tokens one at a time, while <code>PARSE</code> extracts all tokens at once into an array. <code>PARSECOUNT</code> returns the number of tokens found.)
PowerBASIC has a few keywords that make parsing strings trivial: <code>PARSE</code>, <code>PARSE$</code>, and <code>PARSECOUNT</code>. (<code>PARSE$</code>, not shown here, is for extracting tokens one at a time, while <code>PARSE</code> extracts all tokens at once into an array. <code>PARSECOUNT</code> returns the number of tokens found.)


<lang powerbasic>FUNCTION PBMAIN () AS LONG
<syntaxhighlight lang="powerbasic">FUNCTION PBMAIN () AS LONG
DIM parseMe AS STRING
DIM parseMe AS STRING
parseMe = "Hello,How,Are,You,Today"
parseMe = "Hello,How,Are,You,Today"
Line 861: Line 1,080:


MSGBOX outP
MSGBOX outP
END FUNCTION</lang>
END FUNCTION</syntaxhighlight>


==={{header|PureBasic}}===
==={{header|PureBasic}}===


'''As described
'''As described
<lang PureBasic>NewList MyStrings.s()
<syntaxhighlight lang="purebasic">NewList MyStrings.s()


For i=1 To 5
For i=1 To 5
Line 875: Line 1,094:
ForEach MyStrings()
ForEach MyStrings()
Print(MyStrings()+".")
Print(MyStrings()+".")
Next</lang>
Next</syntaxhighlight>


'''Still, easier would be
'''Still, easier would be
<lang PureBasic>Print(ReplaceString("Hello,How,Are,You,Today",",","."))</lang>
<syntaxhighlight lang="purebasic">Print(ReplaceString("Hello,How,Are,You,Today",",","."))</syntaxhighlight>


==={{header|QBasic}}===
==={{header|QBasic}}===
<lang qbasic>DIM parseMe AS STRING
<syntaxhighlight lang="qbasic">DIM parseMe AS STRING
parseMe = "Hello,How,Are,You,Today"
parseMe = "Hello,How,Are,You,Today"


Line 925: Line 1,144:
PRINT "."; parsed(L0);
PRINT "."; parsed(L0);
NEXT
NEXT
END IF</lang>
END IF</syntaxhighlight>


==={{header|Run BASIC}}===
==={{header|Run BASIC}}===
<lang runbasic>text$ = "Hello,How,Are,You,Today"
<syntaxhighlight lang="runbasic">text$ = "Hello,How,Are,You,Today"
FOR i = 1 to 5
FOR i = 1 to 5
textArray$(i) = word$(text$,i,",")
textArray$(i) = word$(text$,i,",")
print textArray$(i);" ";
print textArray$(i);" ";
NEXT</lang>
NEXT</syntaxhighlight>


==={{header|VBScript}}===
==={{header|VBScript}}===
====One liner====
====One liner====
<lang vb>WScript.Echo Join(Split("Hello,How,Are,You,Today", ","), ".")</lang>
<syntaxhighlight lang="vb">WScript.Echo Join(Split("Hello,How,Are,You,Today", ","), ".")</syntaxhighlight>


In fact, the Visual Basic solution (below) could have done the same, as Join() is available.
In fact, the Visual Basic solution (below) could have done the same, as Join() is available.
Line 945: Line 1,164:
Unlike PowerBASIC, there is no need to know beforehand how many tokens are in the string -- <code>Split</code> automagically builds the array for you.
Unlike PowerBASIC, there is no need to know beforehand how many tokens are in the string -- <code>Split</code> automagically builds the array for you.


<lang vb>Sub Main()
<syntaxhighlight lang="vb">Sub Main()
Dim parseMe As String, parsed As Variant
Dim parseMe As String, parsed As Variant
parseMe = "Hello,How,Are,You,Today"
parseMe = "Hello,How,Are,You,Today"
Line 958: Line 1,177:


MsgBox outP
MsgBox outP
End Sub</lang>
End Sub</syntaxhighlight>


=={{header|Batch File}}==
=={{header|Batch File}}==
<lang dos>@echo off
<syntaxhighlight lang="dos">@echo off
setlocal enabledelayedexpansion
setlocal enabledelayedexpansion
call :tokenize %1 res
call :tokenize %1 res
Line 972: Line 1,191:
for %%i in (%str%) do set %2=!%2!.%%i
for %%i in (%str%) do set %2=!%2!.%%i
set %2=!%2:~1!
set %2=!%2:~1!
goto :eof</lang>
goto :eof</syntaxhighlight>


''Demo''
''Demo''
>tokenize.cmd "Hello,How,Are,You,Today"
>tokenize.cmd "Hello,How,Are,You,Today"
Hello.How.Are.You.Today
Hello.How.Are.You.Today

=={{header|BQN}}==
Uses a splitting idiom from bqncrate.
<syntaxhighlight lang="bqn">Split ← (+`׬)⊸-∘= ⊔ ⊢

∾⟜'.'⊸∾´ ',' Split "Hello,How,Are,You,Today"</syntaxhighlight>
{{out}}
<pre>"Hello.How.Are.You.Today"</pre>


=={{header|Bracmat}}==
=={{header|Bracmat}}==
Solution that employs string pattern matching to spot the commas
Solution that employs string pattern matching to spot the commas
<lang bracmat>( "Hello,How,Are,You,Today":?String
<syntaxhighlight lang="bracmat">( "Hello,How,Are,You,Today":?String
& :?ReverseList
& :?ReverseList
& whl
& whl
Line 992: Line 1,219:
)
)
& out$!List
& out$!List
)</lang>
)</syntaxhighlight>
Solution that starts by evaluating the input and employs the circumstance that the comma is a list constructing binary operator and that the string does not contain any other characters that are interpreted as operators on evaluation.
Solution that starts by evaluating the input and employs the circumstance that the comma is a list constructing binary operator and that the string does not contain any other characters that are interpreted as operators on evaluation.
<lang bracmat>( get$("Hello,How,Are,You,Today",MEM):?CommaseparatedList
<syntaxhighlight lang="bracmat">( get$("Hello,How,Are,You,Today",MEM):?CommaseparatedList
& :?ReverseList
& :?ReverseList
& whl
& whl
Line 1,006: Line 1,233:
)
)
& out$!List
& out$!List
)</lang>
)</syntaxhighlight>


=={{header|C}}==
=={{header|C}}==
Line 1,015: Line 1,242:
This example uses the ''strtok()'' function to separate the tokens. This function is destructive (replacing token separators with '\0'), so we have to make a copy of the string (using ''strdup()'') before tokenizing. ''strdup()'' is not part of [[ANSI C]], but is available on most platforms. It can easily be implemented with a combination of ''strlen()'', ''malloc()'', and ''strcpy()''.
This example uses the ''strtok()'' function to separate the tokens. This function is destructive (replacing token separators with '\0'), so we have to make a copy of the string (using ''strdup()'') before tokenizing. ''strdup()'' is not part of [[ANSI C]], but is available on most platforms. It can easily be implemented with a combination of ''strlen()'', ''malloc()'', and ''strcpy()''.


<lang c>#include<string.h>
<syntaxhighlight lang="c">#include<string.h>
#include<stdio.h>
#include<stdio.h>
#include<stdlib.h>
#include<stdlib.h>
Line 1,036: Line 1,263:


return 0;
return 0;
}</lang>
}</syntaxhighlight>


Another way to accomplish the task without the built-in string functions is to temporarily modify the separator character. This method does not need any additional memory, but requires the input string to be writeable.
Another way to accomplish the task without the built-in string functions is to temporarily modify the separator character. This method does not need any additional memory, but requires the input string to be writeable.
<lang c>#include<stdio.h>
<syntaxhighlight lang="c">#include<stdio.h>


typedef void (*callbackfunc)(const char *);
typedef void (*callbackfunc)(const char *);
Line 1,064: Line 1,291:
tokenize(array, ',', doprint);
tokenize(array, ',', doprint);
return 0;
return 0;
}</lang>
}</syntaxhighlight>


=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==
<lang csharp>string str = "Hello,How,Are,You,Today";
<syntaxhighlight lang="csharp">string str = "Hello,How,Are,You,Today";
// or Regex.Split ( "Hello,How,Are,You,Today", "," );
// or Regex.Split ( "Hello,How,Are,You,Today", "," );
// (Regex is in System.Text.RegularExpressions namespace)
// (Regex is in System.Text.RegularExpressions namespace)
string[] strings = str.Split(',');
string[] strings = str.Split(',');
Console.WriteLine(String.Join(".", strings));
Console.WriteLine(String.Join(".", strings));
</syntaxhighlight>
</lang>


=={{header|C++}}==
=={{header|C++}}==
Line 1,079: Line 1,306:
std::getline() is typically used to tokenize strings on a single-character delimiter
std::getline() is typically used to tokenize strings on a single-character delimiter


<lang cpp>#include <string>
<syntaxhighlight lang="cpp">#include <string>
#include <sstream>
#include <sstream>
#include <vector>
#include <vector>
Line 1,094: Line 1,321:
copy(v.begin(), v.end(), std::ostream_iterator<std::string>(std::cout, "."));
copy(v.begin(), v.end(), std::ostream_iterator<std::string>(std::cout, "."));
std::cout << '\n';
std::cout << '\n';
}</lang>
}</syntaxhighlight>


{{works with|C++98}}
{{works with|C++98}}
C++ allows the user to redefine what is considered whitespace. If the delimiter is whitespace, tokenization becomes effortless.
C++ allows the user to redefine what is considered whitespace. If the delimiter is whitespace, tokenization becomes effortless.


<lang cpp>#include <string>
<syntaxhighlight lang="cpp">#include <string>
#include <locale>
#include <locale>
#include <sstream>
#include <sstream>
Line 1,123: Line 1,350:
copy(v.begin(), v.end(), std::ostream_iterator<std::string>(std::cout, "."));
copy(v.begin(), v.end(), std::ostream_iterator<std::string>(std::cout, "."));
std::cout << '\n';
std::cout << '\n';
}</lang>
}</syntaxhighlight>


{{works with|C++98}}
{{works with|C++98}}
Line 1,129: Line 1,356:
The boost library has multiple options for easy tokenization.
The boost library has multiple options for easy tokenization.


<lang cpp>#include <string>
<syntaxhighlight lang="cpp">#include <string>
#include <vector>
#include <vector>
#include <iterator>
#include <iterator>
Line 1,142: Line 1,369:
copy(v.begin(), v.end(), std::ostream_iterator<std::string>(std::cout, "."))
copy(v.begin(), v.end(), std::ostream_iterator<std::string>(std::cout, "."))
std::cout << '\n';
std::cout << '\n';
}</lang>
}</syntaxhighlight>

{{works with|C++23}}
C++20 and C++23 drastically improve the ergonomics of simple manipulation of ranges.

<syntaxhighlight lang="cpp">#include <string>
#include <ranges>
#include <iostream>
int main() {
std::string s = "Hello,How,Are,You,Today";
s = s // Assign the final string back to the string variable
| std::views::split(',') // Produce a range of the comma separated words
| std::views::join_with('.') // Concatenate the words into a single range of characters
| std::ranges::to<std::string>(); // Convert the range of characters into a regular string
std::cout << s;
}</syntaxhighlight>


=={{header|Ceylon}}==
=={{header|Ceylon}}==
{{works with|Ceylon 1.2}}
{{works with|Ceylon 1.2}}
<lang ceylon>shared void tokenizeAString() {
<syntaxhighlight lang="ceylon">shared void tokenizeAString() {
value input = "Hello,How,Are,You,Today";
value input = "Hello,How,Are,You,Today";
value tokens = input.split(','.equals);
value tokens = input.split(','.equals);
print(".".join(tokens));
print(".".join(tokens));
}</lang>
}</syntaxhighlight>

=={{header|CFEngine}}==
<syntaxhighlight lang="cfengine">bundle agent main
{
reports:
"${with}" with => join(".", splitstring("Hello,How,Are,You,Today", ",", 99));
}
</syntaxhighlight>
{{out}}
<pre>cf-agent -KIf ./tokenize-a-string.cf
R: Hello.How.Are.You.Today</pre>

See https://docs.cfengine.com/docs/master/reference-functions.html for a complete list of available functions.


=={{header|Clojure}}==
=={{header|Clojure}}==
Using native Clojure functions and Java Interop:
Using native Clojure functions and Java Interop:
<lang clojure>(apply str (interpose "." (.split #"," "Hello,How,Are,You,Today")))</lang>
<syntaxhighlight lang="clojure">(apply str (interpose "." (.split #"," "Hello,How,Are,You,Today")))</syntaxhighlight>


Using the clojure.string library:
Using the clojure.string library:
<lang clojure>(clojure.string/join "." (clojure.string/split "Hello,How,Are,You,Today" #","))</lang>
<syntaxhighlight lang="clojure">(clojure.string/join "." (clojure.string/split "Hello,How,Are,You,Today" #","))</syntaxhighlight>

=={{header|CLU}}==
<syntaxhighlight lang="clu">% This iterator splits the string on a given character,
% and returns each substring in order.
tokenize = iter (s: string, c: char) yields (string)
while ~string$empty(s) do
next: int := string$indexc(c, s)
if next = 0 then
yield(s)
break
else
yield(string$substr(s, 1, next-1))
s := string$rest(s, next+1)
end
end
end tokenize

start_up = proc ()
po: stream := stream$primary_output()
str: string := "Hello,How,Are,You,Today"
for part: string in tokenize(str, ',') do
stream$putl(po, part || ".")
end
end start_up</syntaxhighlight>
{{out}}
<pre>Hello.
How.
Are.
You.
Today.</pre>


=={{header|COBOL}}==
=={{header|COBOL}}==
This can be made to handle more complex cases; UNSTRING allows multiple delimiters, capture of which delimiter was used for each field, a POINTER for starting position (set on ending), along with match TALLYING.
This can be made to handle more complex cases; UNSTRING allows multiple delimiters, capture of which delimiter was used for each field, a POINTER for starting position (set on ending), along with match TALLYING.


<syntaxhighlight lang="cobol">
<lang COBOL>
identification division.
identification division.
program-id. tokenize.
program-id. tokenize.
Line 1,193: Line 1,479:
goback.
goback.
end program tokenize.
end program tokenize.
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 1,203: Line 1,489:
=={{header|CoffeeScript}}==
=={{header|CoffeeScript}}==


<lang coffeescript>
<syntaxhighlight lang="coffeescript">
arr = "Hello,How,Are,You,Today".split ","
arr = "Hello,How,Are,You,Today".split ","
console.log arr.join "."
console.log arr.join "."
</syntaxhighlight>
</lang>


=={{header|ColdFusion}}==
=={{header|ColdFusion}}==
=== Classic tag based CFML ===
=== Classic tag based CFML ===
<lang cfm>
<syntaxhighlight lang="cfm">
<cfoutput>
<cfoutput>
<cfset wordListTag = "Hello,How,Are,You,Today">
<cfset wordListTag = "Hello,How,Are,You,Today">
#Replace( wordListTag, ",", ".", "all" )#
#Replace( wordListTag, ",", ".", "all" )#
</cfoutput>
</cfoutput>
</syntaxhighlight>
</lang>
{{Output}}
{{Output}}
<pre>
<pre>
Line 1,222: Line 1,508:


=== Script Based CFML ===
=== Script Based CFML ===
<lang cfm><cfscript>
<syntaxhighlight lang="cfm"><cfscript>
wordList = "Hello,How,Are,You,Today";
wordList = "Hello,How,Are,You,Today";
splitList = replace( wordList, ",", ".", "all" );
splitList = replace( wordList, ",", ".", "all" );
writeOutput( splitList );
writeOutput( splitList );
</cfscript></lang>
</cfscript></syntaxhighlight>
{{Output}}
{{Output}}
<pre>
<pre>
Line 1,236: Line 1,522:
There are libraries out there that handle splitting (e.g., [http://www.cliki.net/SPLIT-SEQUENCE SPLIT-SEQUENCE], and the more-general [http://weitz.de/cl-ppcre/ CL-PPCRE]), but this is a simple one-off, too. When the words are written with write-with-periods, there is no final period after the last word.
There are libraries out there that handle splitting (e.g., [http://www.cliki.net/SPLIT-SEQUENCE SPLIT-SEQUENCE], and the more-general [http://weitz.de/cl-ppcre/ CL-PPCRE]), but this is a simple one-off, too. When the words are written with write-with-periods, there is no final period after the last word.


<lang lisp>(defun comma-split (string)
<syntaxhighlight lang="lisp">(defun comma-split (string)
(loop for start = 0 then (1+ finish)
(loop for start = 0 then (1+ finish)
for finish = (position #\, string :start start)
for finish = (position #\, string :start start)
Line 1,243: Line 1,529:


(defun write-with-periods (strings)
(defun write-with-periods (strings)
(format t "~{~A~^.~}" strings))</lang>
(format t "~{~A~^.~}" strings))</syntaxhighlight>


=={{header|Cowgol}}==
=={{header|Cowgol}}==
<lang cowgol>include "cowgol.coh";
<syntaxhighlight lang="cowgol">include "cowgol.coh";
include "strings.coh";
include "strings.coh";


Line 1,285: Line 1,571:
print(".\n");
print(".\n");
i := i + 1;
i := i + 1;
end loop;</lang>
end loop;</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello.
<pre>Hello.
Line 1,294: Line 1,580:


=={{header|Crystal}}==
=={{header|Crystal}}==
<lang crystal>puts "Hello,How,Are,You,Today".split(',').join('.')</lang>
<syntaxhighlight lang="crystal">puts "Hello,How,Are,You,Today".split(',').join('.')</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello.How.Are.You.Today</pre>
<pre>Hello.How.Are.You.Today</pre>


=={{header|D}}==
=={{header|D}}==
<lang d>void main() {
<syntaxhighlight lang="d">void main() {
import std.stdio, std.string;
import std.stdio, std.string;


"Hello,How,Are,You,Today".split(',').join('.').writeln;
"Hello,How,Are,You,Today".split(',').join('.').writeln;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello.How.Are.You.Today</pre>
<pre>Hello.How.Are.You.Today</pre>
Line 1,310: Line 1,596:
=== Using String.split ===
=== Using String.split ===
{{libheader| System.SysUtils}}
{{libheader| System.SysUtils}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program Tokenize_a_string;
program Tokenize_a_string;


Line 1,328: Line 1,614:
end.
end.


</syntaxhighlight>
</lang>


=== Using TStringList ===
=== Using TStringList ===
<syntaxhighlight lang="delphi">
<lang Delphi>
program TokenizeString;
program TokenizeString;


Line 1,364: Line 1,650:


end.
end.
</syntaxhighlight>
</lang>


The result is:
The result is:


<syntaxhighlight lang="delphi">
<lang Delphi>
Hello
Hello
How
How
Line 1,374: Line 1,660:
You
You
Today
Today
</syntaxhighlight>
</lang>

=={{header|dt}}==
<syntaxhighlight lang="dt">"Hello,How,Are,You,Today" "," split "." join pl</syntaxhighlight>


=={{header|Dyalect}}==
=={{header|Dyalect}}==
<syntaxhighlight lang="dyalect">var str = "Hello,How,Are,You,Today"

var strings = str.Split(',')
<lang dyalect>var str = "Hello,How,Are,You,Today"
print(values: strings, separator: ".")</syntaxhighlight>
var strings = str.split(',')
print(values: strings, separator: ".")</lang>

{{out}}
{{out}}

<pre>Hello.How.Are.You.Today</pre>
<pre>Hello.How.Are.You.Today</pre>


=={{header|Déjà Vu}}==
=={{header|Déjà Vu}}==
<lang dejavu>!print join "." split "Hello,How,Are,You,Today" ","</lang>
<syntaxhighlight lang="dejavu">!print join "." split "Hello,How,Are,You,Today" ","</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello.How.Are.You.Today</pre>
<pre>Hello.How.Are.You.Today</pre>


=={{header|E}}==
=={{header|E}}==
<lang e>".".rjoin("Hello,How,Are,You,Today".split(","))</lang>
<syntaxhighlight lang="e">".".rjoin("Hello,How,Are,You,Today".split(","))</syntaxhighlight>

=={{header|EasyLang}}==
<syntaxhighlight lang="easylang">
s$ = "Hello,How,Are,You,Today"
a$[] = strsplit s$ ","
for s$ in a$[]
write s$ & "."
.
</syntaxhighlight>


=={{header|Elena}}==
=={{header|Elena}}==
ELENA 4.x:
ELENA 6.x:
<lang elena>import system'routines;
<syntaxhighlight lang="elena">import system'routines;
import extensions;
import extensions;
public program()
public program()
{
{
var string := "Hello,How,Are,You,Today";
auto string := "Hello,How,Are,You,Today";
string.splitBy:",".forEach:(s)
string.splitBy(",").forEach::(s)
{
{
console.print(s,".")
console.print(s,".")
}
}
}</lang>
}</syntaxhighlight>


=={{header|Elixir}}==
=={{header|Elixir}}==
<lang elixir>
<syntaxhighlight lang="elixir">
tokens = String.split("Hello,How,Are,You,Today", ",")
tokens = String.split("Hello,How,Are,You,Today", ",")
IO.puts Enum.join(tokens, ".")
IO.puts Enum.join(tokens, ".")
</syntaxhighlight>
</lang>

=={{header|EMal}}==
<syntaxhighlight lang="emal">
text value = "Hello,How,Are,You,Today"
List tokens = value.split(",")
writeLine(tokens.join("."))
# single line version
writeLine("Hello,How,Are,You,Today".split(",").join("."))
</syntaxhighlight>
{{out}}
<pre>
Hello.How.Are.You.Today
Hello.How.Are.You.Today
</pre>


=={{header|Erlang}}==
=={{header|Erlang}}==
<lang erlang>-module(tok).
<syntaxhighlight lang="erlang">-module(tok).
-export([start/0]).
-export([start/0]).


Line 1,422: Line 1,731:
Lst = string:tokens("Hello,How,Are,You,Today",","),
Lst = string:tokens("Hello,How,Are,You,Today",","),
io:fwrite("~s~n", [string:join(Lst,".")]),
io:fwrite("~s~n", [string:join(Lst,".")]),
ok.</lang>
ok.</syntaxhighlight>


=={{header|Euphoria}}==
=={{header|Euphoria}}==
<lang euphoria>function split(sequence s, integer c)
<syntaxhighlight lang="euphoria">function split(sequence s, integer c)
sequence out
sequence out
integer first, delim
integer first, delim
Line 1,446: Line 1,755:
for i = 1 to length(s) do
for i = 1 to length(s) do
puts(1, s[i] & ',')
puts(1, s[i] & ',')
end for</lang>
end for</syntaxhighlight>


=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==
<lang fsharp>System.String.Join(".", "Hello,How,Are,You,Today".Split(','))</lang>
<syntaxhighlight lang="fsharp">System.String.Join(".", "Hello,How,Are,You,Today".Split(','))</syntaxhighlight>


=={{header|Factor}}==
=={{header|Factor}}==
<lang factor>"Hello,How,Are,You,Today" "," split "." join print</lang>
<syntaxhighlight lang="factor">"Hello,How,Are,You,Today" "," split "." join print</syntaxhighlight>


=={{header|Falcon}}==
=={{header|Falcon}}==
'''VBA/Python programmer's approach to this solution, not sure if it's the most falconic way'''
'''VBA/Python programmer's approach to this solution, not sure if it's the most falconic way'''
<lang falcon>
<syntaxhighlight lang="falcon">
/* created by Aykayayciti Earl Lamont Montgomery
/* created by Aykayayciti Earl Lamont Montgomery
April 9th, 2018 */
April 9th, 2018 */
Line 1,470: Line 1,779:


> b
> b
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 1,481: Line 1,790:
A string can be split on a given character, returning a list of the intervening strings.
A string can be split on a given character, returning a list of the intervening strings.


<lang fantom>
<syntaxhighlight lang="fantom">
class Main
class Main
{
{
Line 1,494: Line 1,803:
}
}
}
}
</syntaxhighlight>
</lang>

=={{header|Fennel}}==
{{trans|Lua}}
<syntaxhighlight lang="fennel">(fn string.split [self sep]
(let [pattern (string.format "([^%s]+)" sep)
fields {}]
(self:gsub pattern (fn [c] (tset fields (+ 1 (length fields)) c)))
fields))

(let [str "Hello,How,Are,You,Today"]
(print (table.concat (str:split ",") ".")))</syntaxhighlight>


=={{header|Forth}}==
=={{header|Forth}}==
There is no standard string split routine, but it is easily written. The results are saved temporarily to the dictionary.
There is no standard string split routine, but it is easily written. The results are saved temporarily to the dictionary.


<lang forth>: split ( str len separator len -- tokens count )
<syntaxhighlight lang="forth">: split ( str len separator len -- tokens count )
here >r 2swap
here >r 2swap
begin
begin
Line 1,516: Line 1,836:
1 ?do dup 2@ type ." ." cell+ cell+ loop 2@ type ;
1 ?do dup 2@ type ." ." cell+ cell+ loop 2@ type ;


s" Hello,How,Are,You,Today" s" ," split .tokens \ Hello.How.Are.You.Today</lang>
s" Hello,How,Are,You,Today" s" ," split .tokens \ Hello.How.Are.You.Today</syntaxhighlight>


=={{header|Fortran}}==
=={{header|Fortran}}==
{{works with|Fortran|90 and later}}
{{works with|Fortran|90 and later}}
<lang fortran>PROGRAM Example
<syntaxhighlight lang="fortran">PROGRAM Example


CHARACTER(23) :: str = "Hello,How,Are,You,Today"
CHARACTER(23) :: str = "Hello,How,Are,You,Today"
Line 1,542: Line 1,862:
END DO
END DO
END PROGRAM Example</lang>
END PROGRAM Example</syntaxhighlight>


=={{header|Frink}}==
=={{header|Frink}}==
<lang frink>
<syntaxhighlight lang="frink">
println[join[".", split[",", "Hello,How,Are,You,Today"]]]
println[join[".", split[",", "Hello,How,Are,You,Today"]]]
</syntaxhighlight>
</lang>

=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
window 1, @"Tokenize a string"

void local fn DoIt
CFStringRef string = @"Hello,How,Are,You,Today"
CFArrayRef tokens = fn StringComponentsSeparatedByString( string, @"," )
print fn ArrayComponentsJoinedByString( tokens, @"." )
end fn

fn DoIt

HandleEvents
</syntaxhighlight>
{{out}}
<pre>
Hello.How.Are.You.Today
</pre>


=={{header|Gambas}}==
=={{header|Gambas}}==
'''[https://gambas-playground.proko.eu/?gist=218e240236cdf1419a405abfed906ed3 Click this link to run this code]'''
'''[https://gambas-playground.proko.eu/?gist=218e240236cdf1419a405abfed906ed3 Click this link to run this code]'''
<lang gambas>Public Sub Main()
<syntaxhighlight lang="gambas">Public Sub Main()
Dim sString As String[] = Split("Hello,How,Are,You,Today")
Dim sString As String[] = Split("Hello,How,Are,You,Today")


Print sString.Join(".")
Print sString.Join(".")


End</lang>
End</syntaxhighlight>
Output:
Output:
<pre>
<pre>
Line 1,563: Line 1,902:


=={{header|GAP}}==
=={{header|GAP}}==
<lang gap>SplitString("Hello,How,Are,You,Today", ",");
<syntaxhighlight lang="gap">SplitString("Hello,How,Are,You,Today", ",");
# [ "Hello", "How", "Are", "You", "Today" ]
# [ "Hello", "How", "Are", "You", "Today" ]


JoinStringsWithSeparator(last, ".");
JoinStringsWithSeparator(last, ".");
# "Hello.How.Are.You.Today"</lang>
# "Hello.How.Are.You.Today"</syntaxhighlight>


=={{header|Genie}}==
=={{header|Genie}}==
<lang genie>[indent=4]
<syntaxhighlight lang="genie">[indent=4]


init
init
Line 1,576: Line 1,915:
words:array of string[] = str.split(",")
words:array of string[] = str.split(",")
joined:string = string.joinv(".", words)
joined:string = string.joinv(".", words)
print joined</lang>
print joined</syntaxhighlight>


{{out}}
{{out}}
Line 1,584: Line 1,923:


=={{header|Go}}==
=={{header|Go}}==
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 1,594: Line 1,933:
s := "Hello,How,Are,You,Today"
s := "Hello,How,Are,You,Today"
fmt.Println(strings.Join(strings.Split(s, ","), "."))
fmt.Println(strings.Join(strings.Split(s, ","), "."))
}</lang>
}</syntaxhighlight>


=={{header|Groovy}}==
=={{header|Groovy}}==
<lang groovy>println 'Hello,How,Are,You,Today'.split(',').join('.')</lang>
<syntaxhighlight lang="groovy">println 'Hello,How,Are,You,Today'.split(',').join('.')</syntaxhighlight>


=={{header|Haskell}}==
=={{header|Haskell}}==
'''Using Data.Text'''
'''Using Data.Text'''


<lang haskell>{-# OPTIONS_GHC -XOverloadedStrings #-}
<syntaxhighlight lang="haskell">{-# OPTIONS_GHC -XOverloadedStrings #-}
import Data.Text (splitOn,intercalate)
import Data.Text (splitOn,intercalate)
import qualified Data.Text.IO as T (putStrLn)
import qualified Data.Text.IO as T (putStrLn)


main = T.putStrLn . intercalate "." $ splitOn "," "Hello,How,Are,You,Today"</lang>
main = T.putStrLn . intercalate "." $ splitOn "," "Hello,How,Are,You,Today"</syntaxhighlight>


Output: Hello.How.Are.You.Today
Output: Hello.How.Are.You.Today
Line 1,614: Line 1,953:
The necessary operations are unfortunately not in the standard library (yet), but simple to write:
The necessary operations are unfortunately not in the standard library (yet), but simple to write:


<lang haskell>splitBy :: (a -> Bool) -> [a] -> [[a]]
<syntaxhighlight lang="haskell">splitBy :: (a -> Bool) -> [a] -> [[a]]
splitBy _ [] = []
splitBy _ [] = []
splitBy f list = first : splitBy f (dropWhile f rest) where
splitBy f list = first : splitBy f (dropWhile f rest) where
Line 1,629: Line 1,968:
-- using regular expression to split:
-- using regular expression to split:
import Text.Regex
import Text.Regex
putStrLn $ joinWith "." $ splitRegex (mkRegex ",") $ "Hello,How,Are,You,Today"</lang>
putStrLn $ joinWith "." $ splitRegex (mkRegex ",") $ "Hello,How,Are,You,Today"</syntaxhighlight>


Tokenizing can also be realized by using unfoldr and break:
Tokenizing can also be realized by using unfoldr and break:
<lang Haskell>*Main> mapM_ putStrLn $ takeWhile (not.null) $ unfoldr (Just . second(drop 1). break (==',')) "Hello,How,Are,You,Today"
<syntaxhighlight lang="haskell">*Main> mapM_ putStrLn $ takeWhile (not.null) $ unfoldr (Just . second(drop 1). break (==',')) "Hello,How,Are,You,Today"
Hello
Hello
How
How
Are
Are
You
You
Today</lang>
Today</syntaxhighlight>
* You need to import the modules Data.List and Control.Arrow
* You need to import the modules Data.List and Control.Arrow


Line 1,643: Line 1,982:


=={{header|HicEst}}==
=={{header|HicEst}}==
<lang hicest>CHARACTER string="Hello,How,Are,You,Today", list
<syntaxhighlight lang="hicest">CHARACTER string="Hello,How,Are,You,Today", list


nWords = INDEX(string, ',', 256) + 1
nWords = INDEX(string, ',', 256) + 1
Line 1,655: Line 1,994:
DO i = 1, nWords
DO i = 1, nWords
WRITE(APPend) TRIM(CHAR(i, maxWordLength, list)), '.'
WRITE(APPend) TRIM(CHAR(i, maxWordLength, list)), '.'
ENDDO</lang>
ENDDO</syntaxhighlight>


=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==
<lang icon>procedure main()
<syntaxhighlight lang="icon">procedure main()
A := []
A := []
"Hello,How,Are,You,Today" ? {
"Hello,How,Are,You,Today" ? {
Line 1,666: Line 2,005:
every writes(!A,".")
every writes(!A,".")
write()
write()
end</lang>
end</syntaxhighlight>


{{out}}
{{out}}
Line 1,676: Line 2,015:


A Unicon-specific solution is:
A Unicon-specific solution is:
<lang unicon>import util
<syntaxhighlight lang="unicon">import util


procedure main()
procedure main()
Line 1,682: Line 2,021:
every writes(!A,".")
every writes(!A,".")
write()
write()
end</lang>
end</syntaxhighlight>


One wonders what the expected output should be with the input string ",,,,".
One wonders what the expected output should be with the input string ",,,,".


=={{header|Io}}==
=={{header|Io}}==
<lang io>"Hello,How,Are,You,Today" split(",") join(".") println</lang>
<syntaxhighlight lang="io">"Hello,How,Are,You,Today" split(",") join(".") println</syntaxhighlight>


=={{header|J}}==
=={{header|J}}==
<lang j> s=: 'Hello,How,Are,You,Today'
<syntaxhighlight lang="j"> s=: 'Hello,How,Are,You,Today'
] t=: <;._1 ',',s
] t=: <;._1 ',',s
+-----+---+---+---+-----+
+-----+---+---+---+-----+
Line 1,699: Line 2,038:


'.' (I.','=s)}s NB. two steps combined
'.' (I.','=s)}s NB. two steps combined
Hello.How.Are.You.Today</lang>
Hello.How.Are.You.Today</syntaxhighlight>


Alternatively using the system library/script <tt>strings</tt>
Alternatively using the system library/script <tt>strings</tt>
<lang j> require 'strings'
<syntaxhighlight lang="j"> require 'strings'
',' splitstring s
',' splitstring s
+-----+---+---+---+-----+
+-----+---+---+---+-----+
Line 1,709: Line 2,048:


'.' joinstring ',' splitstring s
'.' joinstring ',' splitstring s
Hello.How.Are.You.Today</lang>
Hello.How.Are.You.Today</syntaxhighlight>


<tt>splitstring</tt> and <tt>joinstring</tt> also work with longer "delimiters":
<tt>splitstring</tt> and <tt>joinstring</tt> also work with longer "delimiters":
<lang j> '"'([ ,~ ,) '","' joinstring ',' splitstring s
<syntaxhighlight lang="j"> '"'([ ,~ ,) '","' joinstring ',' splitstring s
"Hello","How","Are","You","Today"</lang>
"Hello","How","Are","You","Today"</syntaxhighlight>


But, of course, this could be solved with simple string replacement:
But, of course, this could be solved with simple string replacement:


<lang J> rplc&',.' s
<syntaxhighlight lang="j"> rplc&',.' s
Hello.How.Are.You.Today</lang>
Hello.How.Are.You.Today</syntaxhighlight>


The task asks us to ''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.'' but for many purposes the original string is an adequate data structure. Note also that given a string, a list of "word start" indices and "word length" integers can be logically equivalent to having an "array of words" -- and, depending on implementation details may be a superior or inferior choice to some other representation. But, in current definition of this task, the concept of "word length" plays no useful role.
The task asks us to ''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.'' but for many purposes the original string is an adequate data structure. Note also that given a string, a list of "word start" indices and "word length" integers can be logically equivalent to having an "array of words" -- and, depending on implementation details may be a superior or inferior choice to some other representation. But, in current definition of this task, the concept of "word length" plays no useful role.
Line 1,724: Line 2,063:
Note also that J provides several built-in concepts of parsing: split on leading delimiter, split on trailing delimiter, split J language words. Also, it's sometimes more efficient to append to a string than to prepend to it. So a common practice for parsing on an embedded delimiter is to append a copy of the delimiter to the string and then use the appended result:
Note also that J provides several built-in concepts of parsing: split on leading delimiter, split on trailing delimiter, split J language words. Also, it's sometimes more efficient to append to a string than to prepend to it. So a common practice for parsing on an embedded delimiter is to append a copy of the delimiter to the string and then use the appended result:


<lang J> fn;._2 string,','</lang>
<syntaxhighlight lang="j"> fn;._2 string,','</syntaxhighlight>


Here '''fn''' is applied to each ',' delimited substring and the results are assembled into an array.
Here '''fn''' is applied to each ',' delimited substring and the results are assembled into an array.


Or, factoring out the names:
Or, factoring out the names:
<lang J> fn ((;._2)(@(,&','))) string</lang>
<syntaxhighlight lang="j"> fn ((;._2)(@(,&','))) string</syntaxhighlight>


=={{header|Java}}==
=={{header|Java}}==
Line 1,740: Line 2,079:
{{works with|Java|1.8+}}
{{works with|Java|1.8+}}


<lang java5>String toTokenize = "Hello,How,Are,You,Today";
<syntaxhighlight lang="java5">String toTokenize = "Hello,How,Are,You,Today";
System.out.println(String.join(".", toTokenize.split(",")));</lang>
System.out.println(String.join(".", toTokenize.split(",")));</syntaxhighlight>


{{works with|Java|1.4+}}
{{works with|Java|1.4+}}
<lang java5>String toTokenize = "Hello,How,Are,You,Today";
<syntaxhighlight lang="java5">String toTokenize = "Hello,How,Are,You,Today";


String words[] = toTokenize.split(",");//splits on one comma, multiple commas yield multiple splits
String words[] = toTokenize.split(",");//splits on one comma, multiple commas yield multiple splits
Line 1,750: Line 2,089:
for(int i=0; i<words.length; i++) {
for(int i=0; i<words.length; i++) {
System.out.print(words[i] + ".");
System.out.print(words[i] + ".");
}</lang>
}</syntaxhighlight>


The other way is to use StringTokenizer. It will skip any empty tokens. So if two commas are given in line, there will be an empty string in the array given by the split function, but no empty string with the StringTokenizer object. This method takes more code to use, but allows you to get tokens incrementally instead of all at once.
The other way is to use StringTokenizer. It will skip any empty tokens. So if two commas are given in line, there will be an empty string in the array given by the split function, but no empty string with the StringTokenizer object. This method takes more code to use, but allows you to get tokens incrementally instead of all at once.


{{works with|Java|1.0+}}
{{works with|Java|1.0+}}
<lang java5>String toTokenize = "Hello,How,Are,You,Today";
<syntaxhighlight lang="java5">String toTokenize = "Hello,How,Are,You,Today";


StringTokenizer tokenizer = new StringTokenizer(toTokenize, ",");
StringTokenizer tokenizer = new StringTokenizer(toTokenize, ",");
while(tokenizer.hasMoreTokens()) {
while(tokenizer.hasMoreTokens()) {
System.out.print(tokenizer.nextToken() + ".");
System.out.print(tokenizer.nextToken() + ".");
}</lang>
}</syntaxhighlight>


=={{header|JavaScript}}==
=={{header|JavaScript}}==
<syntaxhighlight lang="javascript">console.log(
{{works with|Firefox|2.0}}
"Hello,How,Are,You,Today"
.split(",")
.join(".")
);</syntaxhighlight>A more advanced program to tokenise strings:<syntaxhighlight lang="javascript" line="1">
const Tokeniser = (function () {
const numberRegex = /-?(\d+\.d+|\d+\.|\.\d+|\d+)((e|E)(\+|-)?\d+)?/g;
return {
settings: {
operators: ["<", ">", "=", "+", "-", "*", "/", "?", "!"],
separators: [",", ".", ";", ":", " ", "\t", "\n"],
groupers: ["(", ")", "[", "]", "{", "}", '"', '"', "'", "'"],
keepWhiteSpacesAsTokens: false,
trimTokens: true
},
isNumber: function (value) {
if (typeof value === "number") {
return true;
} else if (typeof value === "string") {
return numberRegex.test(value);
}
return false;
},
closeGrouper: function (grouper) {
if (this.settings.groupers.includes(grouper)) {
return this.settings.groupers[this.settings.groupers.indexOf(grouper) + 1];
}
return null;
},
tokenType: function (char) {
if (this.settings.operators.includes(char)) {
return "operator";
} else if (this.settings.separators.includes(char)) {
return "separator";
} else if (this.settings.groupers.includes(char)) {
return "grouper";
}
return "other";
},
parseString: function (str) {
if (typeof str !== "string") {
if (str === null) {
return "null";
} if (typeof str === "object") {
str = JSON.stringify(str);
} else {
str = str.toString();
}
}
let tokens = [], _tempToken = "";
for (let i = 0; i < str.length; i++) {
if (this.tokenType(_tempToken) !== this.tokenType(str[i]) || this.tokenType(str[i]) === "separator") {
if (_tempToken.trim() !== "") {
tokens.push(this.settings.trimTokens ? _tempToken.trim() : _tempToken);
} else if (this.settings.keepWhiteSpacesAsTokens) {
tokens.push(_tempToken);
}
_tempToken = str[i];
if (this.tokenType(_tempToken) === "separator") {
if (_tempToken.trim() !== "") {
tokens.push(this.settings.trimTokens ? _tempToken.trim() : _tempToken);
} else if (this.settings.keepWhiteSpacesAsTokens) {
tokens.push(_tempToken);
}
_tempToken = "";
}
} else {
_tempToken += str[i];
}
}
if (_tempToken.trim() !== "") {
tokens.push(this.settings.trimTokens ? _tempToken.trim() : _tempToken);
} else if (this.settings.keepWhiteSpacesAsTokens) {
tokens.push(_tempToken);
}
return tokens.filter((token) => token !== "");
}
};
})();
</syntaxhighlight>Output:<syntaxhighlight lang="javascript">
Tokeniser.parseString("Hello,How,Are,You,Today");


<lang javascript>alert( "Hello,How,Are,You,Today".split(",").join(".") );</lang>
// -> ['Hello', ',', 'How', ',', 'Are', ',', 'You', ',', 'Today']
</syntaxhighlight>


=={{header|jq}}==
=={{header|jq}}==
<lang jq>split(",") | join(".")</lang>Example:<lang sh>$ jq -r 'split(",") | join(".")'
<syntaxhighlight lang="jq">split(",") | join(".")</syntaxhighlight>Example:<syntaxhighlight lang="sh">$ jq -r 'split(",") | join(".")'
"Hello,How,Are,You,Today"
"Hello,How,Are,You,Today"
Hello.How.Are.You.Today</lang>
Hello.How.Are.You.Today</syntaxhighlight>


=={{header|Jsish}}==
=={{header|Jsish}}==
Being in the ECMAScript family, Jsi is blessed with many easy to use character, string and array manipulation routines.
Being in the ECMAScript family, Jsi is blessed with many easy to use character, string and array manipulation routines.


<lang javascript>puts('Hello,How,Are,You,Today'.split(',').join('.'))</lang>
<syntaxhighlight lang="javascript">puts('Hello,How,Are,You,Today'.split(',').join('.'))</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello.How.Are.You.Today</pre>
<pre>Hello.How.Are.You.Today</pre>


=={{header|Julia}}==
=={{header|Julia}}==
<syntaxhighlight lang="julia">
<lang Julia>
s = "Hello,How,Are,You,Today"
s = "Hello,How,Are,You,Today"
a = split(s, ",")
a = split(s, ",")
Line 1,788: Line 2,208:
println("Splits into ", a)
println("Splits into ", a)
println("Reconstitutes to \"", t, "\"")
println("Reconstitutes to \"", t, "\"")
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 1,798: Line 2,218:


=={{header|K}}==
=={{header|K}}==
<lang K>words: "," \: "Hello,How,Are,You,Today"
<syntaxhighlight lang="k">words: "," \: "Hello,How,Are,You,Today"
"." /: words</lang>
"." /: words</syntaxhighlight>


{{out}}
{{out}}
Line 1,805: Line 2,225:
"Hello.How.Are.You.Today"
"Hello.How.Are.You.Today"
</pre>
</pre>

{{works with|ngn/k}}<syntaxhighlight lang=K>","\"Hello,How,Are,You,Today"
("Hello"
"How"
"Are"
"You"
"Today")</syntaxhighlight>


=={{header|Klingphix}}==
=={{header|Klingphix}}==
<lang Klingphix>( "Hello,How,Are,You,Today" "," ) split len [ get print "." print ] for
<syntaxhighlight lang="klingphix">( "Hello,How,Are,You,Today" "," ) split len [ get print "." print ] for


nl "End " input</lang>
nl "End " input</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello.How.Are.You.Today.
<pre>Hello.How.Are.You.Today.
Line 1,816: Line 2,243:
=={{header|Kotlin}}==
=={{header|Kotlin}}==
{{works with|Kotlin|1.0b4}}
{{works with|Kotlin|1.0b4}}
<lang scala>fun main(args: Array<String>) {
<syntaxhighlight lang="scala">fun main(args: Array<String>) {
val input = "Hello,How,Are,You,Today"
val input = "Hello,How,Are,You,Today"
println(input.split(',').joinToString("."))
println(input.split(',').joinToString("."))
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello.How.Are.You.Today</pre>
<pre>Hello.How.Are.You.Today</pre>


=={{header|Ksh}}==
=={{header|Ksh}}==
<lang ksh>
<syntaxhighlight lang="ksh">
#!/bin/ksh
#!/bin/ksh


Line 1,855: Line 2,282:
######
######


_tokenize "${string}" "${inputdelim}" "${outputdelim}"</lang>
_tokenize "${string}" "${inputdelim}" "${outputdelim}"</syntaxhighlight>
{{out}}<pre>Hello.How.Are.You.Today</pre>
{{out}}<pre>Hello.How.Are.You.Today</pre>


Line 1,863: Line 2,290:


=={{header|Lambdatalk}}==
=={{header|Lambdatalk}}==
<lang scheme>
<syntaxhighlight lang="scheme">
{S.replace , by . in Hello,How,Are,You,Today}.
{S.replace , by . in Hello,How,Are,You,Today}.
-> Hello.How.Are.You.Today.
-> Hello.How.Are.You.Today.
</syntaxhighlight>
</lang>

=={{header|Lang}}==
<syntaxhighlight lang="lang">
$str = Hello,How,Are,You,Today
fn.println(fn.join(\., fn.split($str, \,)))
</syntaxhighlight>


=={{header|Lang5}}==
=={{header|Lang5}}==
<lang lang5>'Hello,How,Are,You,Today ', split '. join .</lang>
<syntaxhighlight lang="lang5">'Hello,How,Are,You,Today ', split '. join .</syntaxhighlight>


=={{header|LDPL}}==
=={{header|LDPL}}==
<lang ldpl>
<syntaxhighlight lang="ldpl">
DATA:
DATA:
explode/words is text vector
explode/words is text vector
Line 1,924: Line 2,357:
add 1 and i in i
add 1 and i in i
repeat
repeat
</syntaxhighlight>
</lang>


=={{header|LFE}}==
=={{header|LFE}}==


<lang lisp>
<syntaxhighlight lang="lisp">
> (set split (string:tokens "Hello,How,Are,You,Today" ","))
> (set split (string:tokens "Hello,How,Are,You,Today" ","))
("Hello" "How" "Are" "You" "Today")
("Hello" "How" "Are" "You" "Today")
> (string:join split ".")
> (string:join split ".")
"Hello.How.Are.You.Today"
"Hello.How.Are.You.Today"
</syntaxhighlight>
</lang>


=={{header|Lingo}}==
=={{header|Lingo}}==
<lang lingo>input = "Hello,How,Are,You,Today"
<syntaxhighlight lang="lingo">input = "Hello,How,Are,You,Today"
_player.itemDelimiter = ","
_player.itemDelimiter = ","
output = ""
output = ""
Line 1,944: Line 2,377:
delete the last char of output
delete the last char of output
put output
put output
-- "Hello.How.Are.You.Today"</lang>
-- "Hello.How.Are.You.Today"</syntaxhighlight>


=={{header|Logo}}==
=={{header|Logo}}==
{{works with|UCB Logo}}
{{works with|UCB Logo}}
<lang logo>to split :str :sep
<syntaxhighlight lang="logo">to split :str :sep
output parse map [ifelse ? = :sep ["| |] [?]] :str
output parse map [ifelse ? = :sep ["| |] [?]] :str
end</lang>
end</syntaxhighlight>


This form is more robust, doing the right thing if there are embedded spaces.
This form is more robust, doing the right thing if there are embedded spaces.
<lang logo>to split :str :by [:acc []] [:w "||]
<syntaxhighlight lang="logo">to split :str :by [:acc []] [:w "||]
if empty? :str [output lput :w :acc]
if empty? :str [output lput :w :acc]
ifelse equal? first :str :by ~
ifelse equal? first :str :by ~
[output (split butfirst :str :by lput :w :acc)] ~
[output (split butfirst :str :by lput :w :acc)] ~
[output (split butfirst :str :by :acc lput first :str :w)]
[output (split butfirst :str :by :acc lput first :str :w)]
end</lang>
end</syntaxhighlight>


<lang logo>? show split "Hello,How,Are,You,Today ",
<syntaxhighlight lang="logo">? show split "Hello,How,Are,You,Today ",
[Hello How Are You Today]</lang>
[Hello How Are You Today]</syntaxhighlight>


=={{header|Logtalk}}==
=={{header|Logtalk}}==
Using Logtalk built-in support for Definite Clause Grammars (DCGs) and representing the strings as atoms for readbility:
Using Logtalk built-in support for Definite Clause Grammars (DCGs) and representing the strings as atoms for readbility:
<lang logtalk>
<syntaxhighlight lang="logtalk">
:- object(spliting).
:- object(spliting).


Line 1,988: Line 2,421:


:- end_object.
:- end_object.
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 1,998: Line 2,431:
=={{header|Lua}}==
=={{header|Lua}}==
Split function callously stolen from the lua-users wiki
Split function callously stolen from the lua-users wiki
<lang Lua>function string:split (sep)
<syntaxhighlight lang="lua">function string:split (sep)
local sep, fields = sep or ":", {}
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
local pattern = string.format("([^%s]+)", sep)
Line 2,006: Line 2,439:


local str = "Hello,How,Are,You,Today"
local str = "Hello,How,Are,You,Today"
print(table.concat(str:split(","), "."))</lang>
print(table.concat(str:split(","), "."))</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello.How.Are.You.Today</pre>
<pre>Hello.How.Are.You.Today</pre>


=={{header|M2000 Interpreter}}==
=={{header|M2000 Interpreter}}==
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module CheckIt {
Module CheckIt {
Function Tokenize$(s){
Function Tokenize$(s){
Line 2,024: Line 2,457:
}
}
Checkit
Checkit
</syntaxhighlight>
</lang>


=={{header|M4}}==
=={{header|M4}}==
<lang M4>define(`s',`Hello,How,Are,You,Today')
<syntaxhighlight lang="m4">define(`s',`Hello,How,Are,You,Today')
define(`set',`define(`$1[$2]',`$3')')
define(`set',`define(`$1[$2]',`$3')')
define(`get',`defn($1[$2])')
define(`get',`defn($1[$2])')
Line 2,037: Line 2,470:
define(`show',
define(`show',
`ifelse(eval(j<n),1,`get(a,j).`'define(`j',incr(j))`'show')')
`ifelse(eval(j<n),1,`get(a,j).`'define(`j',incr(j))`'show')')
show</lang>
show</syntaxhighlight>


{{out}}
{{out}}
Line 2,045: Line 2,478:


=={{header|Maple}}==
=={{header|Maple}}==
<lang Maple>StringTools:-Join(StringTools:-Split("Hello,How,Are,You,Today", ","),".");</lang>
<syntaxhighlight lang="maple">StringTools:-Join(StringTools:-Split("Hello,How,Are,You,Today", ","),".");</syntaxhighlight>
{{Out|Output}}
{{Out|Output}}
<pre>"Hello.How.Are.You.Today"</pre>
<pre>"Hello.How.Are.You.Today"</pre>


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>StringJoin@StringSplit["Hello,How,Are,You,Today", "," -> "."]</lang>
<syntaxhighlight lang="mathematica">StringJoin@StringSplit["Hello,How,Are,You,Today", "," -> "."]</syntaxhighlight>


=={{header|MATLAB}} / {{header|Octave}}==
=={{header|MATLAB}} / {{header|Octave}}==
<syntaxhighlight lang="matlab">
<lang Matlab>
s=strsplit('Hello,How,Are,You,Today',',')
s=strsplit('Hello,How,Are,You,Today',',')
fprintf(1,'%s.',s{:})
fprintf(1,'%s.',s{:})
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 2,064: Line 2,497:


=={{header|Maxima}}==
=={{header|Maxima}}==
<lang Maxima>l: split("Hello,How,Are,You,Today", ",")$
<syntaxhighlight lang="maxima">l: split("Hello,How,Are,You,Today", ",")$
printf(true, "~{~a~^.~}~%", l)$</lang>
printf(true, "~{~a~^.~}~%", l)$</syntaxhighlight>

A slightly different way
<syntaxhighlight lang="maxima">
split("Hello,How,Are,You,Today",",")$
simplode(%,".");
</syntaxhighlight>
{{out}}
<pre>
"Hello.How.Are.You.Today"
</pre>


=={{header|MAXScript}}==
=={{header|MAXScript}}==
<lang maxscript>output = ""
<syntaxhighlight lang="maxscript">output = ""
for word in (filterString "Hello,How,Are,You,Today" ",") do
for word in (filterString "Hello,How,Are,You,Today" ",") do
(
(
output += (word + ".")
output += (word + ".")
)
)
format "%\n" output</lang>
format "%\n" output</syntaxhighlight>


=={{header|Mercury}}==
=={{header|Mercury}}==
<lang>
<syntaxhighlight lang="text">
:- module string_tokenize.
:- module string_tokenize.
:- interface.
:- interface.
Line 2,089: Line 2,532:
Tokens = string.split_at_char((','), "Hello,How,Are,You,Today"),
Tokens = string.split_at_char((','), "Hello,How,Are,You,Today"),
io.write_list(Tokens, ".", io.write_string, !IO),
io.write_list(Tokens, ".", io.write_string, !IO),
io.nl(!IO).</lang>
io.nl(!IO).</syntaxhighlight>


=={{header|min}}==
=={{header|min}}==
{{works with|min|0.19.3}}
{{works with|min|0.19.3}}
<lang min>"Hello,How,Are,You,Today" "," split "." join print</lang>
<syntaxhighlight lang="min">"Hello,How,Are,You,Today" "," split "." join print</syntaxhighlight>


=={{header|MiniScript}}==
=={{header|MiniScript}}==
<lang MiniScript>tokens = "Hello,How,Are,You,Today".split(",")
<syntaxhighlight lang="miniscript">tokens = "Hello,How,Are,You,Today".split(",")
print tokens.join(".")</lang>
print tokens.join(".")</syntaxhighlight>


=={{header|MMIX}}==
=={{header|MMIX}}==
<lang mmix>sep IS ','
<syntaxhighlight lang="mmix">sep IS ','
EOS IS 0
EOS IS 0
NL IS 10
NL IS 10
Line 2,153: Line 2,596:
LDBU t,tp
LDBU t,tp
PBNZ t,2B % UNTIL EOB(uffer)
PBNZ t,2B % UNTIL EOB(uffer)
TRAP 0,Halt,0</lang>
TRAP 0,Halt,0</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 2,165: Line 2,608:


=={{header|Modula-3}}==
=={{header|Modula-3}}==
<lang modula3>MODULE Tokenize EXPORTS Main;
<syntaxhighlight lang="modula3">MODULE Tokenize EXPORTS Main;


IMPORT IO, TextConv;
IMPORT IO, TextConv;
Line 2,182: Line 2,625:
END;
END;
IO.Put("\n");
IO.Put("\n");
END Tokenize.</lang>
END Tokenize.</syntaxhighlight>


=={{header|MUMPS}}==
=={{header|MUMPS}}==
<lang MUMPS>TOKENS
<syntaxhighlight lang="mumps">TOKENS
NEW I,J,INP
NEW I,J,INP
SET INP="Hello,how,are,you,today"
SET INP="Hello,how,are,you,today"
Line 2,191: Line 2,634:
NEW J FOR J=1:1:I WRITE INP(J) WRITE:J'=I "."
NEW J FOR J=1:1:I WRITE INP(J) WRITE:J'=I "."
KILL I,J,INP // Kill is optional. "New" variables automatically are killed on "Quit"
KILL I,J,INP // Kill is optional. "New" variables automatically are killed on "Quit"
QUIT</lang>
QUIT</syntaxhighlight>


In use:
In use:
Line 2,198: Line 2,641:


=={{header|Nanoquery}}==
=={{header|Nanoquery}}==
<lang nanoquery>for word in "Hello,How,Are,You,Today".split(",")
<syntaxhighlight lang="nanoquery">for word in "Hello,How,Are,You,Today".split(",")
print word + "."
print word + "."
end</lang>
end</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello.How.Are.You.Today.</pre>
<pre>Hello.How.Are.You.Today.</pre>


=={{header|Nemerle}}==
=={{header|Nemerle}}==
<lang Nemerle>using System;
<syntaxhighlight lang="nemerle">using System;
using System.Console;
using System.Console;
using Nemerle.Utility.NString;
using Nemerle.Utility.NString;
Line 2,218: Line 2,661:
// a quick in place list comprehension takes care of that
// a quick in place list comprehension takes care of that
}
}
}</lang>
}</syntaxhighlight>


=={{header|NetRexx}}==
=={{header|NetRexx}}==
<lang NetRexx>/*NetRexx program *****************************************************
<syntaxhighlight lang="netrexx">/*NetRexx program *****************************************************
* 20.08.2012 Walter Pachl derived from REXX Version 3
* 20.08.2012 Walter Pachl derived from REXX Version 3
**********************************************************************/
**********************************************************************/
Line 2,232: Line 2,675:
Say ss.word(i)'.'
Say ss.word(i)'.'
End
End
Say 'End-of-list.'</lang>
Say 'End-of-list.'</syntaxhighlight>
Output as in REXX version
Output as in REXX version


=={{header|NewLISP}}==
=={{header|NewLISP}}==
<lang NewLISP>(print (join (parse "Hello,How,Are,You,Today" ",") "."))</lang>
<syntaxhighlight lang="newlisp">(print (join (parse "Hello,How,Are,You,Today" ",") "."))</syntaxhighlight>


=={{header|Nial}}==
=={{header|Nial}}==
Line 2,244: Line 2,687:
Define Array with input string:
Define Array with input string:


<lang Nial> s := 'Hello,How,Are,You,Today'
<syntaxhighlight lang="nial"> s := 'Hello,How,Are,You,Today'
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|H|e|l|l|o|,|H|o|w|,|A|r|e|,|Y|o|u|,|T|o|d|a|y|
|H|e|l|l|o|,|H|o|w|,|A|r|e|,|Y|o|u|,|T|o|d|a|y|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+</lang>
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+</syntaxhighlight>


Split string at the commas:
Split string at the commas:


<lang Nial> t := s eachall = `, cut s
<syntaxhighlight lang="nial"> t := s eachall = `, cut s
+-----------+-------+-------+-------+-----------+
+-----------+-------+-------+-------+-----------+
|+-+-+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+-+-+|
|+-+-+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+-+-+|
||H|e|l|l|o|||H|o|w|||A|r|e|||Y|o|u|||T|o|d|a|y||
||H|e|l|l|o|||H|o|w|||A|r|e|||Y|o|u|||T|o|d|a|y||
|+-+-+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+-+-+|
|+-+-+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+-+-+|
+-----------+-------+-------+-------+-----------+</lang>
+-----------+-------+-------+-------+-----------+</syntaxhighlight>


Join string with <code>.</code> and remove last <code>.</code>
Join string with <code>.</code> and remove last <code>.</code>


<lang Nial> u := front content (cart t `.)
<syntaxhighlight lang="nial"> u := front content (cart t `.)
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|H|e|l|l|o|.|H|o|w|.|A|r|e|.|Y|o|u|.|T|o|d|a|y|
|H|e|l|l|o|.|H|o|w|.|A|r|e|.|Y|o|u|.|T|o|d|a|y|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+</lang>
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+</syntaxhighlight>


Less cluttered display, using <code>set "sketch;set "nodecor</code> display switches.
Less cluttered display, using <code>set "sketch;set "nodecor</code> display switches.


<lang Nial> s:='Hello,How,Are,You,Today'
<syntaxhighlight lang="nial"> s:='Hello,How,Are,You,Today'
Hello,How,Are,You,Today
Hello,How,Are,You,Today
t:= s eachall = `, cut s
t:= s eachall = `, cut s
Line 2,274: Line 2,717:
+-----+---+---+---+-----+
+-----+---+---+---+-----+
u:=front content (cart t `.)
u:=front content (cart t `.)

Hello.How.Are.You.Today</lang>
Hello.How.Are.You.Today</syntaxhighlight>

Or as a one-liner:

<syntaxhighlight lang="nial">
front content (cart (s eachall = `, cut s) `.)
</syntaxhighlight>


=={{header|Nim}}==
=={{header|Nim}}==
<lang nim>import strutils
<syntaxhighlight lang="nim">import strutils


let text = "Hello,How,Are,You,Today"
let text = "Hello,How,Are,You,Today"
let tokens = text.split(',')
let tokens = text.split(',')
echo tokens.join(".")</lang>
echo tokens.join(".")</syntaxhighlight>


{{out}}
{{out}}
Line 2,287: Line 2,737:


=={{header|Objeck}}==
=={{header|Objeck}}==
<lang objeck>
<syntaxhighlight lang="objeck">
class Parse {
class Parse {
function : Main(args : String[]) ~ Nil {
function : Main(args : String[]) ~ Nil {
Line 2,295: Line 2,745:
};
};
}
}
}</lang>
}</syntaxhighlight>


=={{header|Objective-C}}==
=={{header|Objective-C}}==
Line 2,302: Line 2,752:
{{works with|Cocoa}}
{{works with|Cocoa}}


<lang objc>NSString *text = @"Hello,How,Are,You,Today";
<syntaxhighlight lang="objc">NSString *text = @"Hello,How,Are,You,Today";
NSArray *tokens = [text componentsSeparatedByString:@","];
NSArray *tokens = [text componentsSeparatedByString:@","];
NSString *result = [tokens componentsJoinedByString:@"."];
NSString *result = [tokens componentsJoinedByString:@"."];
NSLog(result);</lang>
NSLog(result);</syntaxhighlight>


=={{header|OCaml}}==
=={{header|OCaml}}==
To split on a single-character separator:
To split on a single-character separator:
<lang ocaml>let words = String.split_on_char ',' "Hello,How,Are,You,Today" in
<syntaxhighlight lang="ocaml">let words = String.split_on_char ',' "Hello,How,Are,You,Today" in
String.concat "." words
String.concat "." words
</syntaxhighlight>
</lang>


The function split_on_char has been introduced in OCaml 4.04. In previous versions, it could be implemented by:
The function split_on_char has been introduced in OCaml 4.04. In previous versions, it could be implemented by:


<lang ocaml>let split_on_char sep s =
<syntaxhighlight lang="ocaml">let split_on_char sep s =
let r = ref [] in
let r = ref [] in
let j = ref (String.length s) in
let j = ref (String.length s) in
Line 2,324: Line 2,774:
end
end
done;
done;
String.sub s 0 !j :: !r</lang>
String.sub s 0 !j :: !r</syntaxhighlight>


=={{header|Oforth}}==
=={{header|Oforth}}==


<lang Oforth>"Hello,How,Are,You,Today" wordsWith(',') println</lang>
<syntaxhighlight lang="oforth">"Hello,How,Are,You,Today" wordsWith(',') println</syntaxhighlight>


{{out}}
{{out}}
Line 2,336: Line 2,786:


=={{header|ooRexx}}==
=={{header|ooRexx}}==
<lang ooRexx>text='Hello,How,Are,You,Today'
<syntaxhighlight lang="oorexx">text='Hello,How,Are,You,Today'
do while text \= ''
do while text \= ''
parse var text word1 ',' text
parse var text word1 ',' text
call charout 'STDOUT:',word1'.'
call charout 'STDOUT:',word1'.'
end</lang>
end</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello.How.Are.You.Today.</pre>
<pre>Hello.How.Are.You.Today.</pre>


=={{header|OpenEdge/Progress}}==
=={{header|OpenEdge/Progress}}==
<lang progress>FUNCTION tokenizeString RETURNS CHAR (
<syntaxhighlight lang="progress">FUNCTION tokenizeString RETURNS CHAR (
i_c AS CHAR
i_c AS CHAR
):
):
Line 2,368: Line 2,818:
MESSAGE
MESSAGE
tokenizeString( "Hello,How,Are,You,Today" )
tokenizeString( "Hello,How,Are,You,Today" )
VIEW-AS ALERT-BOX.</lang>
VIEW-AS ALERT-BOX.</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 2,381: Line 2,831:


=={{header|Oz}}==
=={{header|Oz}}==
<lang oz>for T in {String.tokens "Hello,How,Are,You,Today" &,} do
<syntaxhighlight lang="oz">for T in {String.tokens "Hello,How,Are,You,Today" &,} do
{System.printInfo T#"."}
{System.printInfo T#"."}
end</lang>
end</syntaxhighlight>


=={{header|PARI/GP}}==
=={{header|PARI/GP}}==
Line 2,393: Line 2,843:
{{Works with|PARI/GP|2.7.4 and above}}
{{Works with|PARI/GP|2.7.4 and above}}


<lang parigp>
<syntaxhighlight lang="parigp">
\\ Tokenize a string str according to 1 character delimiter d. Return a list of tokens.
\\ Tokenize a string str according to 1 character delimiter d. Return a list of tokens.
\\ Using ssubstr() from http://rosettacode.org/wiki/Substring#PARI.2FGP
\\ Using ssubstr() from http://rosettacode.org/wiki/Substring#PARI.2FGP
Line 2,411: Line 2,861:
print("3.",tokenize(",Hello,,How,Are,You,Today",","));
print("3.",tokenize(",Hello,,How,Are,You,Today",","));
}
}
</lang>
</syntaxhighlight>


{{Output}}
{{Output}}
Line 2,429: Line 2,879:
{{Works with|PARI/GP|2.7.4 and above}}
{{Works with|PARI/GP|2.7.4 and above}}


<lang parigp>
<syntaxhighlight lang="parigp">
\\ Tokenize a string str according to 1 character delimiter d. Return a list of tokens.
\\ Tokenize a string str according to 1 character delimiter d. Return a list of tokens.
\\ Using ssubstr() from http://rosettacode.org/wiki/Substring#PARI.2FGP
\\ Using ssubstr() from http://rosettacode.org/wiki/Substring#PARI.2FGP
Line 2,458: Line 2,908:
print("7. 0 pp: ", stok("",","));
print("7. 0 pp: ", stok("",","));
}
}
</lang>
</syntaxhighlight>


{{Output}}
{{Output}}
Line 2,474: Line 2,924:
=={{header|Pascal}}==
=={{header|Pascal}}==
{{works with|Free_Pascal}}
{{works with|Free_Pascal}}
<lang pascal>program TokenizeString;
<syntaxhighlight lang="pascal">program TokenizeString;


{$mode objfpc}{$H+}
{$mode objfpc}{$H+}
Line 2,498: Line 2,948:
Tokens.Free;
Tokens.Free;
end;
end;
end.</lang>
end.</syntaxhighlight>


The result is:
The result is:
Line 2,505: Line 2,955:


=={{header|Perl}}==
=={{header|Perl}}==
<lang perl>print join('.', split /,/, 'Hello,How,Are,You,Today'), "\n";</lang>
<syntaxhighlight lang="perl">print join('.', split /,/, 'Hello,How,Are,You,Today'), "\n";</syntaxhighlight>
CLI one-liner form:
CLI one-liner form:
<lang perl>echo "Hello,How,Are,You,Today" | perl -aplF/,/ -e '$" = "."; $_ = "@F";'</lang>
<syntaxhighlight lang="perl">echo "Hello,How,Are,You,Today" | perl -aplF/,/ -e '$" = "."; $_ = "@F";'</syntaxhighlight>
which is a compact way of telling Perl to do
which is a compact way of telling Perl to do
<lang perl>BEGIN { $/ = "\n"; $\ = "\n"; }
<syntaxhighlight lang="perl">BEGIN { $/ = "\n"; $\ = "\n"; }
LINE: while (defined($_ = <ARGV>)) {
LINE: while (defined($_ = <ARGV>)) {
chomp $_;
chomp $_;
Line 2,518: Line 2,968:
continue {
continue {
die "-p destination: $!\n" unless print $_;
die "-p destination: $!\n" unless print $_;
}</lang>
}</syntaxhighlight>


=={{header|Phix}}==
=={{header|Phix}}==
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">split</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"Hello,How,Are,You,Today"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">","</span><span style="color: #0000FF;">),</span><span style="color: #008000;">"."</span><span style="color: #0000FF;">)</span>
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">split</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"Hello,How,Are,You,Today"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">","</span><span style="color: #0000FF;">),</span><span style="color: #008000;">"."</span><span style="color: #0000FF;">)</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{Out}}
{{Out}}
<pre>
<pre>
Line 2,530: Line 2,980:


=={{header|Phixmonti}}==
=={{header|Phixmonti}}==
<lang Phixmonti>/# "Hello,How,Are,You,Today" "," "." subst print #/
<syntaxhighlight lang="phixmonti">/# "Hello,How,Are,You,Today" "," "." subst print #/
"Hello,How,Are,You,Today" "," " " subst split len for get print "." print endfor</lang>
"Hello,How,Are,You,Today" "," " " subst split len for get print "." print endfor</syntaxhighlight>


=={{header|PHP}}==
=={{header|PHP}}==
{{works with|PHP|5.x}}
{{works with|PHP|5.x}}


<lang php><?php
<syntaxhighlight lang="php"><?php
$str = 'Hello,How,Are,You,Today';
$str = 'Hello,How,Are,You,Today';
echo implode('.', explode(',', $str));
echo implode('.', explode(',', $str));
?></lang>
?></syntaxhighlight>

=={{header|Picat}}==
Using the built-in functions <code>split/2</code> and <code>join/2</code>.
<syntaxhighlight lang="picat">import util.

go =>
S = "Hello,How,Are,You,Today",
T = S.split(","),
println(T),
T.join(".").println(),

% As a one liner:
S.split(",").join(".").println().</syntaxhighlight>

{{out}}
<pre>[Hello,How,Are,You,Today]
Hello.How.Are.You.Today
Hello.How.Are.You.Today</pre>


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
<lang PicoLisp>(mapcar pack
<syntaxhighlight lang="picolisp">(mapcar pack
(split (chop "Hello,How,Are,You,Today") ",") )</lang>
(split (chop "Hello,How,Are,You,Today") ",") )</syntaxhighlight>


=={{header|Pike}}==
=={{header|Pike}}==
<lang pike>("Hello,How,Are,You,Today" / ",") * ".";</lang>
<syntaxhighlight lang="pike">("Hello,How,Are,You,Today" / ",") * ".";</syntaxhighlight>


=={{header|PL/I}}==
=={{header|PL/I}}==
<lang pli>tok: Proc Options(main);
<syntaxhighlight lang="pli">tok: Proc Options(main);
declare s character (100) initial ('Hello,How,Are,You,Today');
declare s character (100) initial ('Hello,How,Are,You,Today');
declare n fixed binary (31);
declare n fixed binary (31);
Line 2,571: Line 3,039:
put skip list (string(table));
put skip list (string(table));
end;
end;
end;</lang>
end;</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello.How.Are.You.Today</pre>
<pre>Hello.How.Are.You.Today</pre>


=={{header|PL/M}}==
=={{header|PL/M}}==
<lang plm>100H:
<syntaxhighlight lang="plm">100H:
/* CP/M CALLS */
/* CP/M CALLS */
BDOS: PROCEDURE (FN, ARG); DECLARE FN BYTE, ARG ADDRESS; GO TO 5; END BDOS;
BDOS: PROCEDURE (FN, ARG); DECLARE FN BYTE, ARG ADDRESS; GO TO 5; END BDOS;
Line 2,615: Line 3,083:


CALL EXIT;
CALL EXIT;
EOF;</lang>
EOF;</syntaxhighlight>
{{out}}
{{out}}
<pre>HELLO. HOW. ARE. YOU. TODAY. </pre>
<pre>HELLO. HOW. ARE. YOU. TODAY. </pre>


=={{header|Plain English}}==
=={{header|Plain English}}==
<lang plainenglish>To run:
<syntaxhighlight lang="plainenglish">To run:
Start up.
Start up.
Split "Hello,How,Are,You,Today" into some string things given the comma byte.
Split "Hello,How,Are,You,Today" into some string things given the comma byte.
Line 2,636: Line 3,104:
If the string thing's next is not nil, append the byte to the string.
If the string thing's next is not nil, append the byte to the string.
Put the string thing's next into the string thing.
Put the string thing's next into the string thing.
Repeat.</lang>
Repeat.</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 2,649: Line 3,117:
First show the use of sysparse_string to break up a string and make a list of strings.
First show the use of sysparse_string to break up a string and make a list of strings.


<lang pop11>;;; Make a list of strings from a string using space as separator
<syntaxhighlight lang="pop11">;;; Make a list of strings from a string using space as separator
lvars list;
lvars list;
sysparse_string('the cat sat on the mat') -> list;
sysparse_string('the cat sat on the mat') -> list;
;;; print the list of strings
;;; print the list of strings
list =>
list =>
** [the cat sat on the mat]</lang>
** [the cat sat on the mat]</syntaxhighlight>


By giving it an extra parameter 'true' we can make it recognize numbers and produce a list of strings and numbers
By giving it an extra parameter 'true' we can make it recognize numbers and produce a list of strings and numbers


<lang pop11>lvars list;
<syntaxhighlight lang="pop11">lvars list;
sysparse_string('one 1 two 2 three 3 four 4', true) -> list;
sysparse_string('one 1 two 2 three 3 four 4', true) -> list;
;;; print the list of strings and numbers
;;; print the list of strings and numbers
Line 2,667: Line 3,135:
** <true>
** <true>
isinteger(list(2))=>
isinteger(list(2))=>
** <true></lang>
** <true></syntaxhighlight>


Now show some uses of the built in procedure sys_parse_string, which allows more options:
Now show some uses of the built in procedure sys_parse_string, which allows more options:


<lang pop11>;;; Make pop-11 print strings with quotes
<syntaxhighlight lang="pop11">;;; Make pop-11 print strings with quotes
true -> pop_pr_quotes;
true -> pop_pr_quotes;
;;;
;;;
Line 2,685: Line 3,153:
;;; print the list of strings
;;; print the list of strings
strings =>
strings =>
** ['Hello' 'How' 'Are' 'You' 'Today']</lang>
** ['Hello' 'How' 'Are' 'You' 'Today']</syntaxhighlight>


If {% ... %} were used instead of [% ... %] the result would be
If {% ... %} were used instead of [% ... %] the result would be
a vector (i.e. array) of strings rather than a list of strings.
a vector (i.e. array) of strings rather than a list of strings.


<lang pop11>{% sys_parse_string(str, `,`) %} -> strings;
<syntaxhighlight lang="pop11">{% sys_parse_string(str, `,`) %} -> strings;
;;; print the vector
;;; print the vector
strings =>
strings =>
** {'Hello' 'How' 'Are' 'You' 'Today'}</lang>
** {'Hello' 'How' 'Are' 'You' 'Today'}</syntaxhighlight>
It is also possible to give sys_parse_string a 'conversion' procedure, which is applied to each of the tokens.
It is also possible to give sys_parse_string a 'conversion' procedure, which is applied to each of the tokens.
E.g. it could be used to produce a vector of numbers, using the conversion procedure 'strnumber', which converts a string to a number:
E.g. it could be used to produce a vector of numbers, using the conversion procedure 'strnumber', which converts a string to a number:


<lang pop11>lvars numbers;
<syntaxhighlight lang="pop11">lvars numbers;
{% sys_parse_string('100 101 102 103 99.9 99.999', strnumber) %} -> numbers;
{% sys_parse_string('100 101 102 103 99.9 99.999', strnumber) %} -> numbers;
;;; the result is a vector containing integers and floats,
;;; the result is a vector containing integers and floats,
;;; which can be printed thus:
;;; which can be printed thus:
numbers =>
numbers =>
** {100 101 102 103 99.9 99.999}</lang>
** {100 101 102 103 99.9 99.999}</syntaxhighlight>


Using lower level pop-11 facilities to tokenise the string:
Using lower level pop-11 facilities to tokenise the string:


<lang pop11>;;; Declare and initialize variables
<syntaxhighlight lang="pop11">;;; Declare and initialize variables
lvars str='Hello,How,Are,You,Today';
lvars str='Hello,How,Are,You,Today';
;;; Iterate over string
;;; Iterate over string
Line 2,724: Line 3,192:
endif;
endif;
;;; Reverse the list
;;; Reverse the list
rev(ls) -> ls;</lang>
rev(ls) -> ls;</syntaxhighlight>


Since the task requires to use array we convert list to array
Since the task requires to use array we convert list to array


<lang pop11>;;; Put list elements and lenght on the stack
<syntaxhighlight lang="pop11">;;; Put list elements and lenght on the stack
destlist(ls);
destlist(ls);
;;; Build a vector from them
;;; Build a vector from them
Line 2,736: Line 3,204:
printf(ar(i), '%s.');
printf(ar(i), '%s.');
endfor;
endfor;
printf('\n');</lang>
printf('\n');</syntaxhighlight>


We could use list directly for printing:
We could use list directly for printing:


<lang pop11>for i in ls do
<syntaxhighlight lang="pop11">for i in ls do
printf(i, '%s.');
printf(i, '%s.');
endfor;</lang>
endfor;</syntaxhighlight>


so the conversion to vector is purely to satisfy task formulation.
so the conversion to vector is purely to satisfy task formulation.
Line 2,748: Line 3,216:
=={{header|PowerShell}}==
=={{header|PowerShell}}==
{{works with|PowerShell|1}}
{{works with|PowerShell|1}}
<lang powershell>$words = "Hello,How,Are,You,Today".Split(',')
<syntaxhighlight lang="powershell">$words = "Hello,How,Are,You,Today".Split(',')
[string]::Join('.', $words)</lang>
[string]::Join('.', $words)</syntaxhighlight>


{{works with|PowerShell|2}}
{{works with|PowerShell|2}}
<lang powershell>$words = "Hello,How,Are,You,Today" -split ','
<syntaxhighlight lang="powershell">$words = "Hello,How,Are,You,Today" -split ','
$words -join '.'</lang>
$words -join '.'</syntaxhighlight>


{{works with|PowerShell|2}}
{{works with|PowerShell|2}}
The StringSplitOptions enumeration weeds out the return of empty elements.
The StringSplitOptions enumeration weeds out the return of empty elements.
<syntaxhighlight lang="powershell">
<lang PowerShell>
"Hello,How,Are,You,Today", ",,Hello,,Goodbye,," | ForEach-Object {($_.Split(',',[StringSplitOptions]::RemoveEmptyEntries)) -join "."}
"Hello,How,Are,You,Today", ",,Hello,,Goodbye,," | ForEach-Object {($_.Split(',',[StringSplitOptions]::RemoveEmptyEntries)) -join "."}
</syntaxhighlight>
</lang>
{{Out}}
{{Out}}
<pre>
<pre>
Line 2,768: Line 3,236:
=={{header|Prolog}}==
=={{header|Prolog}}==
{{works with|SWI Prolog}}
{{works with|SWI Prolog}}
<lang prolog>splitup(Sep,[token(B)|BL]) --> splitup(Sep,B,BL).
<syntaxhighlight lang="prolog">splitup(Sep,[token(B)|BL]) --> splitup(Sep,B,BL).
splitup(Sep,[A|AL],B) --> [A], {\+ [A] = Sep }, splitup(Sep,AL,B).
splitup(Sep,[A|AL],B) --> [A], {\+ [A] = Sep }, splitup(Sep,AL,B).
splitup(Sep,[],[B|BL]) --> Sep, splitup(Sep,B,BL).
splitup(Sep,[],[B|BL]) --> Sep, splitup(Sep,B,BL).
Line 2,776: Line 3,244:
phrase(splitup(".",Tokens),Backtogether),
phrase(splitup(".",Tokens),Backtogether),
string_to_list(ABack,Backtogether),
string_to_list(ABack,Backtogether),
writeln(ABack).</lang>
writeln(ABack).</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 2,788: Line 3,256:
this can be accomplished in a few lines in the top level:
this can be accomplished in a few lines in the top level:


<lang prolog>
<syntaxhighlight lang="prolog">
?- split_string("Hello,How,Are,You,Today", ",", "", Split),
?- split_string("Hello,How,Are,You,Today", ",", "", Split),
| atomics_to_string(Split, ".", PeriodSeparated),
| atomics_to_string(Split, ".", PeriodSeparated),
| writeln(PeriodSeparated).
| writeln(PeriodSeparated).
Hello.How.Are.You.Today
Hello.How.Are.You.Today
</syntaxhighlight>
</lang>


=={{header|Python}}==
=={{header|Python}}==
{{works with|Python|2.5}}{{works with|Python|3.0}}
{{works with|Python|2.5}}{{works with|Python|3.0}}


<lang python>text = "Hello,How,Are,You,Today"
<syntaxhighlight lang="python">text = "Hello,How,Are,You,Today"
tokens = text.split(',')
tokens = text.split(',')
print ('.'.join(tokens))</lang>
print ('.'.join(tokens))</syntaxhighlight>


Or if interpretation of the task description means you don't need to keep an intermediate array:
Or if interpretation of the task description means you don't need to keep an intermediate array:
<lang python>print ('.'.join('Hello,How,Are,You,Today'.split(',')))</lang>
<syntaxhighlight lang="python">print ('.'.join('Hello,How,Are,You,Today'.split(',')))</syntaxhighlight>


=={{header|Q}}==
=={{header|Q}}==
<lang Q>words: "," vs "Hello,How,Are,You,Today"
<syntaxhighlight lang="q">words: "," vs "Hello,How,Are,You,Today"
"." sv words</lang>
"." sv words</syntaxhighlight>


{{out}}
{{out}}
Line 2,814: Line 3,282:
=={{header|QB64}}==
=={{header|QB64}}==
''CBTJD'': 2020/03/12
''CBTJD'': 2020/03/12
<lang vb>a$ = "Hello,How,Are,You,Today" ' | Initialize original string.
<syntaxhighlight lang="vb">a$ = "Hello,How,Are,You,Today" ' | Initialize original string.
FOR na = 1 TO LEN(a$) ' | Start loop to count number of commas.
FOR na = 1 TO LEN(a$) ' | Start loop to count number of commas.
IF MID$(a$, na, 1) = "," THEN nc = nc + 1 ' | For each comma, increment nc.
IF MID$(a$, na, 1) = "," THEN nc = nc + 1 ' | For each comma, increment nc.
Line 2,832: Line 3,300:
PRINT LEFT$(tf$, LEN(tf$) - 1) ' | Print all but the last period of tf$.
PRINT LEFT$(tf$, LEN(tf$) - 1) ' | Print all but the last period of tf$.
END ' | Program end.
END ' | Program end.
</syntaxhighlight>
</lang>


'''Alternative method using word$ function:'''
'''Alternative method using word$ function:'''
----
----
''CBTJD'': 2020/03/12
''CBTJD'': 2020/03/12
<lang vb>a$ = "Hello,How,Are,You,Today" ' | Initialize original string.
<syntaxhighlight lang="vb">a$ = "Hello,How,Are,You,Today" ' | Initialize original string.
DIM t$(LEN(a$) / 2) ' | Create an overestimated sized array.
DIM t$(LEN(a$) / 2) ' | Create an overestimated sized array.
FOR nd = 1 TO LEN(a$) ' | Start loop to find each comma.
FOR nd = 1 TO LEN(a$) ' | Start loop to find each comma.
Line 2,865: Line 3,333:
DONE: ' | Label for bail destination of word count error check.
DONE: ' | Label for bail destination of word count error check.
END FUNCTION ' | End of function.
END FUNCTION ' | End of function.
</syntaxhighlight>
</lang>


=={{header|Quackery}}==
=={{header|Quackery}}==


<lang Quackery> [ [] [] rot
<syntaxhighlight lang="quackery"> [ [] [] rot
witheach
witheach
[ dup char , = iff
[ dup char , = iff
Line 2,878: Line 3,346:
[ witheach [ echo$ say "." ] ] is display ( [ --> )
[ witheach [ echo$ say "." ] ] is display ( [ --> )
$ "Hello,How,Are,You,Today" tokenise display</lang>
$ "Hello,How,Are,You,Today" tokenise display</syntaxhighlight>


{{Out}}
{{Out}}
Line 2,885: Line 3,353:


=={{header|R}}==
=={{header|R}}==
<lang R>text <- "Hello,How,Are,You,Today"
<syntaxhighlight lang="r">text <- "Hello,How,Are,You,Today"
junk <- strsplit(text, split=",")
junk <- strsplit(text, split=",")
print(paste(unlist(junk), collapse="."))</lang>
print(paste(unlist(junk), collapse="."))</syntaxhighlight>


or the one liner
or the one liner


<lang R>paste(unlist(strsplit(text, split=",")), collapse=".")</lang>
<syntaxhighlight lang="r">paste(unlist(strsplit(text, split=",")), collapse=".")</syntaxhighlight>


=={{header|Racket}}==
=={{header|Racket}}==


<lang racket>
<syntaxhighlight lang="racket">
#lang racket
#lang racket
(string-join (string-split "Hello,How,Are,You,Today" ",") ".")
(string-join (string-split "Hello,How,Are,You,Today" ",") ".")
;; -> "Hello.How.Are.You.Today"
;; -> "Hello.How.Are.You.Today"
</syntaxhighlight>
</lang>


=={{header|Raku}}==
=={{header|Raku}}==
(formerly Perl 6)
(formerly Perl 6)
{{works with|Rakudo|#22 "Thousand Oaks"}}
{{works with|Rakudo|#22 "Thousand Oaks"}}
<lang perl6>'Hello,How,Are,You,Today'.split(',').join('.').say;</lang>
<syntaxhighlight lang="raku" line>'Hello,How,Are,You,Today'.split(',').join('.').say;</syntaxhighlight>


Or with function calls:
Or with function calls:


<lang perl6>say join '.', split ',', 'Hello,How,Are,You,Today';</lang>
<syntaxhighlight lang="raku" line>say join '.', split ',', 'Hello,How,Are,You,Today';</syntaxhighlight>


=={{header|Raven}}==
=={{header|Raven}}==
<lang raven>'Hello,How,Are,You,Today' ',' split '.' join print</lang>
<syntaxhighlight lang="raven">'Hello,How,Are,You,Today' ',' split '.' join print</syntaxhighlight>


=={{header|REBOL}}==
=={{header|REBOL}}==
<lang REBOL>print ["Original:" original: "Hello,How,Are,You,Today"]
<syntaxhighlight lang="rebol">print ["Original:" original: "Hello,How,Are,You,Today"]
tokens: parse original ","
tokens: parse original ","
dotted: "" repeat i tokens [append dotted rejoin [i "."]]
dotted: "" repeat i tokens [append dotted rejoin [i "."]]
print ["Dotted: " dotted]</lang>
print ["Dotted: " dotted]</syntaxhighlight>


{{out}}
{{out}}
Line 2,926: Line 3,394:


=={{header|Red}}==
=={{header|Red}}==
<lang Red>str: "Hello,How,Are,You,Today"
<syntaxhighlight lang="red">str: "Hello,How,Are,You,Today"
>> tokens: split str ","
>> tokens: split str ","
>> probe tokens
>> probe tokens
Line 2,933: Line 3,401:
>> periods: replace/all form tokens " " "." ;The word FORM converts the list series to a string removing quotes.
>> periods: replace/all form tokens " " "." ;The word FORM converts the list series to a string removing quotes.
>> print periods ;then REPLACE/ALL spaces with period
>> print periods ;then REPLACE/ALL spaces with period
Hello.How.Are.You.Today</lang>
Hello.How.Are.You.Today</syntaxhighlight>


=={{header|Retro}}==
=={{header|Retro}}==
<syntaxhighlight lang="retro">{{
<lang Retro>{{
: char ( -$ ) " " ;
: char ( -$ ) " " ;
: tokenize ( $-$$ )
: tokenize ( $-$$ )
Line 2,948: Line 3,416:
[ tokenize action dup 1 <> ] while drop
[ tokenize action dup 1 <> ] while drop
^buffer'get drop ;
^buffer'get drop ;
}}</lang>
}}</syntaxhighlight>


This will suffice to split a string into an array of substrings. It is used like this:
This will suffice to split a string into an array of substrings. It is used like this:


<lang Retro>create strings 100 allot
<syntaxhighlight lang="retro">create strings 100 allot
"Hello,How,Are,You,Today" ', strings split</lang>
"Hello,How,Are,You,Today" ', strings split</syntaxhighlight>


Since the buffer' vocabulary creates a zero-terminated buffer, we can display it using the each@ combinator and a simple quote:
Since the buffer' vocabulary creates a zero-terminated buffer, we can display it using the each@ combinator and a simple quote:


<lang Retro>strings [ @ "%s." puts ] ^types'STRING each@</lang>
<syntaxhighlight lang="retro">strings [ @ "%s." puts ] ^types'STRING each@</syntaxhighlight>


=={{header|REXX}}==
=={{header|REXX}}==
===version 1===
===version 1===
This REXX version doesn't append a period to the last word in the list.
This REXX version doesn't append a period to the last word in the list.
<lang rexx>/*REXX program separates a string of comma─delimited words, and echoes them ──► terminal*/
<syntaxhighlight lang="rexx">/*REXX program separates a string of comma─delimited words, and echoes them ──► terminal*/
original = 'Hello,How,Are,You,Today' /*some words separated by commas (,). */
original = 'Hello,How,Are,You,Today' /*some words separated by commas (,). */
say 'The input string:' original /*display original string ──► terminal.*/
say 'The input string:' original /*display original string ──► terminal.*/
Line 2,974: Line 3,442:
say @.j || left(., j\==#) /*maybe append a period (.) to a word. */
say @.j || left(., j\==#) /*maybe append a period (.) to a word. */
end /*j*/ /* [↑] don't append a period if last. */
end /*j*/ /* [↑] don't append a period if last. */
say center(' End─of─list ', 40, "═") /*display a (EOL) trailer for the list.*/</lang>
say center(' End─of─list ', 40, "═") /*display a (EOL) trailer for the list.*/</syntaxhighlight>
{{out|output|text=&nbsp; when using the internal default input:}}
{{out|output|text=&nbsp; when using the internal default input:}}
<pre>
<pre>
Line 2,992: Line 3,460:


Hello,Betty Sue,How,Are,You,Today
Hello,Betty Sue,How,Are,You,Today
<lang rexx>/*REXX program to separate a string of comma-delimited words and echo */
<syntaxhighlight lang="rexx">/*REXX program to separate a string of comma-delimited words and echo */
sss='Hello,How,Are,You,Today'
sss='Hello,How,Are,You,Today'
say 'input string='sss
say 'input string='sss
Line 3,003: Line 3,471:
say word(ss,i)dot
say word(ss,i)dot
End
End
say 'End-of-list.'</lang>
say 'End-of-list.'</syntaxhighlight>
'''output''' is similar to REXX version 1.
'''output''' is similar to REXX version 1.


=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>
<syntaxhighlight lang="ring">
see substr("Hello,How,Are,You,Today", ",", ".")
see substr("Hello,How,Are,You,Today", ",", ".")
</syntaxhighlight>
</lang>

=={{header|RPL}}==
The program below fully complies with the task requirements, e.g. the input string is converted to a list of words, then the list is converted to a string.
{{works with|Halcyon Calc|4.2.8}}
{| class="wikitable"
! RPL code
! Comment
|-
|
"}" + "{" SWAP + STR→
1 OVER SIZE '''FOR''' j
DUP j GET →STR 2 OVER SIZE 1 - SUB j SWAP PUT
'''NEXT'''
"" 1 3 PICK SIZE '''FOR''' j
OVER j GET +
'''IF''' OVER SIZE j ≠ '''THEN''' "." + '''END'''
'''NEXT''' SWAP DROP
≫ '<span style="color:blue">'''TOKNZ'''</span>' STO
|
<span style="color:blue">'''TOKNZ'''</span> ''<span style="color:grey">( "word,word" → "word.word" )</span> ''
convert string into list (words being between quotes)
loop for each list item
convert it to a string, remove quotes at beginning and end
loop for each list item
add item to output string
if not last item, append "."
clean stack
return output string
|}

"Hello,How,Are,You,Today" <span style="color:blue">'''TOKNZ'''</span>
</pre>
'''Output:'''
<span style="color:grey"> 1:</span> "Hello.How.Are.You.Today"
If direct string-to-string conversion is allowed, then this one-liner for HP-48+ will do the job:
≪ 1 OVER SIZE '''FOR''' j '''IF''' DUP j DUP SUB "," == '''THEN''' j "." REPL '''END NEXT''' ≫ '<span style="color:blue">'''TOKNZ'''</span>' STO


=={{header|Ruby}}==
=={{header|Ruby}}==
<lang ruby>puts "Hello,How,Are,You,Today".split(',').join('.')</lang>
<syntaxhighlight lang="ruby">puts "Hello,How,Are,You,Today".split(',').join('.')</syntaxhighlight>


=={{header|Rust}}==
=={{header|Rust}}==
<lang rust>fn main() {
<syntaxhighlight lang="rust">fn main() {
let s = "Hello,How,Are,You,Today";
let s = "Hello,How,Are,You,Today";
let tokens: Vec<&str> = s.split(",").collect();
let tokens: Vec<&str> = s.split(",").collect();
println!("{}", tokens.join("."));
println!("{}", tokens.join("."));
}</lang>
}</syntaxhighlight>


=={{header|S-lang}}==
=={{header|S-lang}}==
<lang S-lang>variable a = strchop("Hello,How,Are,You,Today", ',', 0);
<syntaxhighlight lang="s-lang">variable a = strchop("Hello,How,Are,You,Today", ',', 0);
print(strjoin(a, "."));</lang>
print(strjoin(a, "."));</syntaxhighlight>


{{out}}
{{out}}
Line 3,029: Line 3,535:


=={{header|Scala}}==
=={{header|Scala}}==
<lang scala>println("Hello,How,Are,You,Today" split "," mkString ".")</lang>
<syntaxhighlight lang="scala">println("Hello,How,Are,You,Today" split "," mkString ".")</syntaxhighlight>


=={{header|Scheme}}==
=={{header|Scheme}}==
{{works with|Guile}}
{{works with|Guile}}
<lang scheme>(use-modules (ice-9 regex))
<syntaxhighlight lang="scheme">(use-modules (ice-9 regex))
(define s "Hello,How,Are,You,Today")
(define s "Hello,How,Are,You,Today")
(define words (map match:substring (list-matches "[^,]+" s)))
(define words (map match:substring (list-matches "[^,]+" s)))
Line 3,040: Line 3,546:
(display (list-ref words n))
(display (list-ref words n))
(if (< n (- (length words) 1))
(if (< n (- (length words) 1))
(display ".")))</lang>
(display ".")))</syntaxhighlight>


(with SRFI 13)
(with SRFI 13)
<lang scheme>(define s "Hello,How,Are,You,Today")
<syntaxhighlight lang="scheme">(define s "Hello,How,Are,You,Today")
(define words (string-tokenize s (char-set-complement (char-set #\,))))
(define words (string-tokenize s (char-set-complement (char-set #\,))))
(define t (string-join words "."))</lang>
(define t (string-join words "."))</syntaxhighlight>


{{works with|Gauche Scheme}}
{{works with|Gauche Scheme}}
<lang Scheme>(print
<syntaxhighlight lang="scheme">(print
(string-join
(string-join
(string-split "Hello,How,Are,You,Today" #\,)
(string-split "Hello,How,Are,You,Today" #\,)
".")) </lang>
".")) </syntaxhighlight>
{{output}}
{{output}}
<pre>
<pre>
Line 3,058: Line 3,564:


=={{header|Seed7}}==
=={{header|Seed7}}==
<lang seed7>var array string: tokens is 0 times "";
<syntaxhighlight lang="seed7">var array string: tokens is 0 times "";


tokens := split("Hello,How,Are,You,Today", ",");</lang>
tokens := split("Hello,How,Are,You,Today", ",");</syntaxhighlight>


=={{header|Self}}==
=={{header|Self}}==
<lang self>| s = 'Hello,How,Are,You,Today' |
<syntaxhighlight lang="self">| s = 'Hello,How,Are,You,Today' |
((s splitOn: ',') joinUsing: '.') printLine.
((s splitOn: ',') joinUsing: '.') printLine.
</syntaxhighlight>
</lang>


=={{header|Sidef}}==
=={{header|Sidef}}==
<lang ruby>'Hello,How,Are,You,Today'.split(',').join('.').say;</lang>
<syntaxhighlight lang="ruby">'Hello,How,Are,You,Today'.split(',').join('.').say;</syntaxhighlight>
=={{header|Simula}}==
=={{header|Simula}}==
<lang simula>BEGIN
<syntaxhighlight lang="simula">BEGIN


CLASS TEXTARRAY(N); INTEGER N;
CLASS TEXTARRAY(N); INTEGER N;
Line 3,120: Line 3,626:


END.
END.
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>HELLO.HOW.ARE.YOU.TODAY.</pre>
<pre>HELLO.HOW.ARE.YOU.TODAY.</pre>


=={{header|Slate}}==
=={{header|Slate}}==
<lang slate>('Hello,How,Are,You,Today' splitWith: $,) join &separator: '.'.</lang>
<syntaxhighlight lang="slate">('Hello,How,Are,You,Today' splitWith: $,) join &separator: '.'.</syntaxhighlight>

=={{header|Slope}}==
<syntaxhighlight lang="slope">(display
(list->string
(string->list
"Hello,How,Are,You,Today"
",")
"."))</syntaxhighlight>
{{out}}
<pre>Hello.How.Are.You.Today</pre>


=={{header|Smalltalk}}==
=={{header|Smalltalk}}==
<lang smalltalk>|array |
<syntaxhighlight lang="smalltalk">|array |
array := 'Hello,How,Are,You,Today' subStrings: $,.
array := 'Hello,How,Are,You,Today' subStrings: $,.
array fold: [:concatenation :string | concatenation, '.', string ]</lang>
array fold: [:concatenation :string | concatenation, '.', string ]</syntaxhighlight>


Some implementations also have a ''join:'' convenience method that allows the following shorter solution:
Some implementations also have a ''join:'' convenience method that allows the following shorter solution:


<lang smalltalk>('Hello,How,Are,You,Today' subStrings: $,) join: '.'</lang>
<syntaxhighlight lang="smalltalk">('Hello,How,Are,You,Today' subStrings: $,) join: '.'</syntaxhighlight>


The solution displaying a trailing period would be:
The solution displaying a trailing period would be:


<lang smalltalk>|array |
<syntaxhighlight lang="smalltalk">|array |
array := 'Hello,How,Are,You,Today' subStrings: $,.
array := 'Hello,How,Are,You,Today' subStrings: $,.
array inject: '' into: [:concatenation :string | concatenation, string, '.' ]</lang>
array inject: '' into: [:concatenation :string | concatenation, string, '.' ]</syntaxhighlight>


=={{header|SNOBOL4}}==
=={{header|SNOBOL4}}==
Line 3,146: Line 3,662:
For this task, it's convenient to define Perl-style split( ) and join( ) functions.
For this task, it's convenient to define Perl-style split( ) and join( ) functions.


<lang SNOBOL4> define('split(chs,str)i,j,t,w2') :(split_end)
<syntaxhighlight lang="snobol4"> define('split(chs,str)i,j,t,w2') :(split_end)
split t = table()
split t = table()
sp1 str pos(0) (break(chs) | rem) $ t<i = i + 1>
sp1 str pos(0) (break(chs) | rem) $ t<i = i + 1>
Line 3,162: Line 3,678:
* # Test and display
* # Test and display
output = join('.',split(',','Hello,How,Are,You,Today'))
output = join('.',split(',','Hello,How,Are,You,Today'))
end</lang>
end</syntaxhighlight>


{{out}}
{{out}}
Line 3,170: Line 3,686:


=={{header|Standard ML}}==
=={{header|Standard ML}}==
<lang sml>val splitter = String.tokens (fn c => c = #",");
<syntaxhighlight lang="sml">val splitter = String.tokens (fn c => c = #",");
val main = (String.concatWith ".") o splitter;</lang>
val main = (String.concatWith ".") o splitter;</syntaxhighlight>


Test:
Test:


<lang sml>- main "Hello,How,Are,You,Today"
<syntaxhighlight lang="sml">- main "Hello,How,Are,You,Today"
val it = "Hello.How.Are.You.Today" : string</lang>
val it = "Hello.How.Are.You.Today" : string</syntaxhighlight>


=={{header|Swift}}==
=={{header|Swift}}==


{{works with|Swift|3.x}}
{{works with|Swift|3.x}}
<lang swift>let text = "Hello,How,Are,You,Today"
<syntaxhighlight lang="swift">let text = "Hello,How,Are,You,Today"
let tokens = text.components(separatedBy: ",") // for single or multi-character separator
let tokens = text.components(separatedBy: ",") // for single or multi-character separator
print(tokens)
print(tokens)
let result = tokens.joined(separator: ".")
let result = tokens.joined(separator: ".")
print(result)</lang>
print(result)</syntaxhighlight>


{{works with|Swift|2.x}}
{{works with|Swift|2.x}}
<lang swift>let text = "Hello,How,Are,You,Today"
<syntaxhighlight lang="swift">let text = "Hello,How,Are,You,Today"
let tokens = text.characters.split(",").map{String($0)} // for single-character separator
let tokens = text.characters.split(",").map{String($0)} // for single-character separator
print(tokens)
print(tokens)
let result = tokens.joinWithSeparator(".")
let result = tokens.joinWithSeparator(".")
print(result)</lang>
print(result)</syntaxhighlight>


{{works with|Swift|1.x}}
{{works with|Swift|1.x}}
<lang swift>let text = "Hello,How,Are,You,Today"
<syntaxhighlight lang="swift">let text = "Hello,How,Are,You,Today"
let tokens = split(text, { $0 == "," }) // for single-character separator
let tokens = split(text, { $0 == "," }) // for single-character separator
println(tokens)
println(tokens)
let result = ".".join(tokens)
let result = ".".join(tokens)
println(result)</lang>
println(result)</syntaxhighlight>


For multi-character separators:<lang swift>import Foundation
For multi-character separators:<syntaxhighlight lang="swift">import Foundation


let text = "Hello,How,Are,You,Today"
let text = "Hello,How,Are,You,Today"
let tokens = text.componentsSeparatedByString(",")
let tokens = text.componentsSeparatedByString(",")
print(tokens)</lang>
print(tokens)</syntaxhighlight>


=={{header|Tcl}}==
=={{header|Tcl}}==
Generating a list form a string by splitting on a comma:
Generating a list form a string by splitting on a comma:
<lang tcl>split $string ","</lang>
<syntaxhighlight lang="tcl">split $string ","</syntaxhighlight>


Joining the elements of a list by a period:
Joining the elements of a list by a period:
<lang tcl>join $list "."</lang>
<syntaxhighlight lang="tcl">join $list "."</syntaxhighlight>


Thus the whole thing would look like this:
Thus the whole thing would look like this:
<lang tcl>puts [join [split "Hello,How,Are,You,Today" ","] "."]</lang>
<syntaxhighlight lang="tcl">puts [join [split "Hello,How,Are,You,Today" ","] "."]</syntaxhighlight>


If you'd like to retain the list in a variable with the name "words", it would only be marginally more complex:
If you'd like to retain the list in a variable with the name "words", it would only be marginally more complex:
<lang tcl>puts [join [set words [split "Hello,How,Are,You,Today" ","]] "."]</lang>
<syntaxhighlight lang="tcl">puts [join [set words [split "Hello,How,Are,You,Today" ","]] "."]</syntaxhighlight>


(In general, the <tt>regexp</tt> command is also used in Tcl for tokenization of strings, but this example does not need that level of complexity.)
(In general, the <tt>regexp</tt> command is also used in Tcl for tokenization of strings, but this example does not need that level of complexity.)
Line 3,225: Line 3,741:
<code>tr</code> knows nothing about arrays, so this solution only changes each comma to a period.
<code>tr</code> knows nothing about arrays, so this solution only changes each comma to a period.


<lang bash>echo 'Hello,How,Are,You,Today' | tr ',' '.'</lang>
<syntaxhighlight lang="bash">echo 'Hello,How,Are,You,Today' | tr ',' '.'</syntaxhighlight>

=={{header|Transd}}==
<syntaxhighlight lang="Scheme">#lang transd

MainModule: {
_start: (lambda locals: s "Hello,How,Are,You,Today"
(textout (join (split s ",") "."))
)
}</syntaxhighlight>
{{out}}
<pre>
Hello.How.Are.You.Today
</pre>


=={{header|TUSCRIPT}}==
=={{header|TUSCRIPT}}==
<lang tuscript>
<syntaxhighlight lang="tuscript">
$$ MODE TUSCRIPT
$$ MODE TUSCRIPT
SET string="Hello,How,Are,You,Today"
SET string="Hello,How,Are,You,Today"
SET string=SPLIT (string,":,:")
SET string=SPLIT (string,":,:")
SET string=JOIN (string,".")
SET string=JOIN (string,".")
</syntaxhighlight>
</lang>


=={{header|TXR}}==
=={{header|TXR}}==
Line 3,240: Line 3,769:
sequences of non-commas.
sequences of non-commas.


<lang txr>@(next :list "Hello,How,Are,You,Today")
<syntaxhighlight lang="txr">@(next :list "Hello,How,Are,You,Today")
@(coll)@{token /[^,]+/}@(end)
@(coll)@{token /[^,]+/}@(end)
@(output)
@(output)
@(rep)@token.@(last)@token@(end)
@(rep)@token.@(last)@token@(end)
@(end)</lang>
@(end)</syntaxhighlight>


Different approach. Collect tokens, each of
Different approach. Collect tokens, each of
Line 3,250: Line 3,779:
before a comma, or else extends to the end of the line.
before a comma, or else extends to the end of the line.


<lang txr>@(next :list "Hello,How,Are,You,Today")
<syntaxhighlight lang="txr">@(next :list "Hello,How,Are,You,Today")
@(coll)@(maybe)@token,@(or)@token@(end)@(end)
@(coll)@(maybe)@token,@(or)@token@(end)@(end)
@(output)
@(output)
@(rep)@token.@(last)@token@(end)
@(rep)@token.@(last)@token@(end)
@(end)</lang>
@(end)</syntaxhighlight>


Using TXR Lisp:
Using TXR Lisp:


<lang bash>txr -p '(cat-str (split-str "Hello,How,Are,You,Today" ",") ".")'
<syntaxhighlight lang="bash">txr -p '(cat-str (split-str "Hello,How,Are,You,Today" ",") ".")'
Hello.How.Are.You.Today</lang>
Hello.How.Are.You.Today</syntaxhighlight>


=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==
{{works with|Bourne Shell}}
{{works with|Bourne Shell}}
<lang bash>string='Hello,How,Are,You,Today'
<syntaxhighlight lang="bash">string='Hello,How,Are,You,Today'


(IFS=,
(IFS=,
printf '%s.' $string
printf '%s.' $string
echo)</lang>
echo)</syntaxhighlight>


----
----
{{works with|Bourne Again SHell}}
{{works with|Bourne Again SHell}}
{{works with|Public Domain Korn SHell|5.2.14}}
{{works with|Public Domain Korn SHell|5.2.14}}
<lang bash>#! /bin/bash
<syntaxhighlight lang="bash">#! /bin/bash
stripchar-l ()
stripchar-l ()
#removes the specified character from the left side of the string
#removes the specified character from the left side of the string
Line 3,329: Line 3,858:
join "$( split "$list" "$input_delimiter" )" \
join "$( split "$list" "$input_delimiter" )" \
"$contains_a_space" "$output_delimiter";
"$contains_a_space" "$output_delimiter";
}</lang>
}</syntaxhighlight>


''Example''
''Example''


<lang bash> strtokenize "Hello,How,Are,You,Today" "," "."
<syntaxhighlight lang="bash"> strtokenize "Hello,How,Are,You,Today" "," "."
Hello.How.Are.You.Today </lang>
Hello.How.Are.You.Today </syntaxhighlight>


----
----
Line 3,342: Line 3,871:
{{works with|ksh93}}
{{works with|ksh93}}
{{works with|zsh}}
{{works with|zsh}}
<syntaxhighlight lang="sh">
<lang sh>
string1="Hello,How,Are,You,Today"
string1="Hello,How,Are,You,Today"
elements_quantity=$(echo $string1|tr "," "\n"|wc -l)
elements_quantity=$(echo $string1|tr "," "\n"|wc -l)
Line 3,355: Line 3,884:


# or to cheat
# or to cheat
echo "Hello,How,Are,You,Today"|tr "," "."</lang>
echo "Hello,How,Are,You,Today"|tr "," "."</syntaxhighlight>


=={{header|UnixPipes}}==
=={{header|UnixPipes}}==
{{works with|Bourne Shell}}
{{works with|Bourne Shell}}
<lang bash>token() {
<syntaxhighlight lang="bash">token() {
(IFS=, read -r A B; echo "$A".; test -n "$B" && (echo "$B" | token))
(IFS=, read -r A B; echo "$A".; test -n "$B" && (echo "$B" | token))
}
}


echo "Hello,How,Are,You" | token</lang>
echo "Hello,How,Are,You" | token</syntaxhighlight>


=={{header|Ursa}}==
=={{header|Ursa}}==
<lang ursa>decl string text
<syntaxhighlight lang="ursa">decl string text
set text "Hello,How,Are,You,Today"
set text "Hello,How,Are,You,Today"
decl string<> tokens
decl string<> tokens
Line 3,373: Line 3,902:
out tokens<i> "." console
out tokens<i> "." console
end for
end for
out endl console</lang>
out endl console</syntaxhighlight>


=={{header|Ursala}}==
=={{header|Ursala}}==
Line 3,381: Line 3,910:
second order function parameterized by the delimiter. Character
second order function parameterized by the delimiter. Character
literals are preceded by a backquote.
literals are preceded by a backquote.
<lang Ursala>#import std
<syntaxhighlight lang="ursala">#import std


token_list = sep`, 'Hello,How,Are,You,Today'
token_list = sep`, 'Hello,How,Are,You,Today'
Line 3,387: Line 3,916:
#cast %s
#cast %s


main = mat`. token_list</lang>
main = mat`. token_list</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 3,394: Line 3,923:


=={{header|Vala}}==
=={{header|Vala}}==
<lang Vala>void main() {
<syntaxhighlight lang="vala">void main() {
string s = "Hello,How,Are,You,Today";
string s = "Hello,How,Are,You,Today";
print(@"$(string.joinv(".", s.split(",")))");
print(@"$(string.joinv(".", s.split(",")))");
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello.How.Are.You.Today</pre>
<pre>Hello.How.Are.You.Today</pre>


=={{header|VBA}}==
=={{header|VBA}}==
<lang vb>Sub Main()
<syntaxhighlight lang="vb">Sub Main()
Dim temp() As String
Dim temp() As String
temp = Tokenize("Hello,How,Are,You,Today", ",")
temp = Tokenize("Hello,How,Are,You,Today", ",")
Line 3,414: Line 3,943:
Private Sub Display(arr() As String, sep As String)
Private Sub Display(arr() As String, sep As String)
Debug.Print Join(arr, sep)
Debug.Print Join(arr, sep)
End Sub</lang>
End Sub</syntaxhighlight>
{{Out}}
{{Out}}
<pre>Hello How Are You Today</pre>
<pre>Hello How Are You Today</pre>


=={{header|VBScript}}==
=={{header|VBScript}}==
<syntaxhighlight lang="vb">
<lang vb>
s = "Hello,How,Are,You,Today"
s = "Hello,How,Are,You,Today"
WScript.StdOut.Write Join(Split(s,","),".")
WScript.StdOut.Write Join(Split(s,","),".")
</syntaxhighlight>
</lang>
{{Out}}
{{Out}}
<pre>Hello.How.Are.You.Today</pre>
<pre>Hello.How.Are.You.Today</pre>
Line 3,432: Line 3,961:
The contents of each text register is then displayed to user, separated by a period.
The contents of each text register is then displayed to user, separated by a period.


<lang vedit>Buf_Switch(Buf_Free)
<syntaxhighlight lang="vedit">Buf_Switch(Buf_Free)
Ins_Text("Hello,How,Are,You,Today")
Ins_Text("Hello,How,Are,You,Today")


Line 3,451: Line 3,980:
}
}


Buf_Quit(OK)</lang>
Buf_Quit(OK)</syntaxhighlight>

=={{header|V (Vlang)}}==
<syntaxhighlight lang="go">// Tokenize a string, in V (Vlang)
// Tectonics: v run tokenize-a-string.v
module main

// starts here
pub fn main() {
println("Hello,How,Are,You,Today".split(',').join('.'))
}</syntaxhighlight>
{{out}}
<pre>prompt$ v run rosetta/tokenize-a-string.v
Hello.How.Are.You.Today</pre>


=={{header|WinBatch}}==
=={{header|WinBatch}}==


<lang WinBatch>text = 'Hello,How,Are,You,Today'
<syntaxhighlight lang="winbatch">text = 'Hello,How,Are,You,Today'
result = ''
result = ''
BoxOpen('WinBatch Tokenizing Example', '')
BoxOpen('WinBatch Tokenizing Example', '')
Line 3,463: Line 4,005:
next
next
display(10, 'End of Program', 'Dialog and program will close momentarily.')
display(10, 'End of Program', 'Dialog and program will close momentarily.')
BoxShut()</lang>
BoxShut()</syntaxhighlight>


{{out}}
{{out}}
Line 3,469: Line 4,011:


=={{header|Wortel}}==
=={{header|Wortel}}==
<lang wortel>@join "." @split "," "Hello,How,Are,You,Today"</lang>
<syntaxhighlight lang="wortel">@join "." @split "," "Hello,How,Are,You,Today"</syntaxhighlight>
Returns
Returns
<pre>"Hello.How.Are.You.Today"</pre>
<pre>"Hello.How.Are.You.Today"</pre>


=={{header|Wren}}==
=={{header|Wren}}==
<lang ecmascript>var s = "Hello,How,Are,You,Today"
<syntaxhighlight lang="wren">var s = "Hello,How,Are,You,Today"
var t = s.split(",").join(".") + "."
var t = s.split(",").join(".") + "."
System.print(t)</lang>
System.print(t)</syntaxhighlight>


{{out}}
{{out}}
Line 3,484: Line 4,026:


=={{header|XPath 2.0}}==
=={{header|XPath 2.0}}==
<lang XPath>string-join(tokenize("Hello,How,Are,You,Today", ","), ".")</lang>
<syntaxhighlight lang="xpath">string-join(tokenize("Hello,How,Are,You,Today", ","), ".")</syntaxhighlight>


{{out}}
{{out}}
Line 3,490: Line 4,032:


=={{header|XPL0}}==
=={{header|XPL0}}==
<lang XPL0>string 0;
<syntaxhighlight lang="xpl0">string 0;
include c:\cxpl\codes;
include c:\cxpl\codes;
int I, J, K, Char;
int I, J, K, Char;
Line 3,509: Line 4,051:
for K:= 4 downto 0 do [Text(0, addr Array(K,0)); ChOut(0, ^.)];
for K:= 4 downto 0 do [Text(0, addr Array(K,0)); ChOut(0, ^.)];
CrLf(0);
CrLf(0);
]</lang>
]</syntaxhighlight>


The 'addr' operator is used to fetch the 32-bit address of Array rather
The 'addr' operator is used to fetch the 32-bit address of Array rather
Line 3,520: Line 4,062:


=={{header|Yabasic}}==
=={{header|Yabasic}}==
<lang Yabasic>dim s$(1)
<syntaxhighlight lang="yabasic">dim s$(1)


n = token("Hello. How are you today?", s$(), ".? ")
n = token("Hello. How are you today?", s$(), ".? ")
Line 3,528: Line 4,070:
if i < n print ".";
if i < n print ".";
next
next
print</lang>
print</syntaxhighlight>


=={{header|Zig}}==
<syntaxhighlight lang="zig">const std = @import("std");
pub fn main() void {
const string = "Hello,How,Are,You,Today";
var tokens = std.mem.split(u8, string, ",");
std.debug.print("{s}", .{tokens.next().?});
while (tokens.next()) |token| {
std.debug.print(".{s}", .{token});
}
}</syntaxhighlight>
=={{header|zkl}}==
=={{header|zkl}}==
<lang zkl>"Hello,How,Are,You,Today".split(",").concat(".").println();
<syntaxhighlight lang="zkl">"Hello,How,Are,You,Today".split(",").concat(".").println();
Hello.How.Are.You.Today</lang>
Hello.How.Are.You.Today</syntaxhighlight>


=={{header|Zoea}}==
=={{header|Zoea}}==
<syntaxhighlight lang="zoea">
<lang Zoea>
program: tokenize_a_string
program: tokenize_a_string
input: "Hello,How,Are,You,Today"
input: "Hello,How,Are,You,Today"
output: "Hello.How.Are.You.Today"
output: "Hello.How.Are.You.Today"
</syntaxhighlight>
</lang>


=={{header|Zoea Visual}}==
=={{header|Zoea Visual}}==
Line 3,545: Line 4,097:


=={{header|Zsh}}==
=={{header|Zsh}}==
<lang zsh>str='Hello,How,Are,You,Today'
<syntaxhighlight lang="zsh">str='Hello,How,Are,You,Today'
tokens=(${(s:,:)str})
tokens=(${(s:,:)str})
print ${(j:.:)tokens}</lang>
print ${(j:.:)tokens}</syntaxhighlight>


Or, using SH_SPLIT_WORD:
Or, using SH_SPLIT_WORD:


<lang zsh>str='Hello,How,Are,You,Today'
<syntaxhighlight lang="zsh">str='Hello,How,Are,You,Today'
IFS=, echo ${(j:.:)${=str}}</lang>
IFS=, echo ${(j:.:)${=str}}</syntaxhighlight>


{{omit from|PARI/GP|No real capacity for string manipulation}}
{{omit from|PARI/GP|No real capacity for string manipulation}}

Latest revision as of 14:45, 14 February 2024

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 (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.


Other tasks related to string operations:
Metrics
Counting
Remove/replace
Anagrams/Derangements/shuffling
Find/Search/Determine
Formatting
Song lyrics/poems/Mad Libs/phrases
Tokenize
Sequences



11l

Translation of: Python
V text = ‘Hello,How,Are,You,Today’
V tokens = text.split(‘,’)
print(tokens.join(‘.’))
Output:
Hello.How.Are.You.Today

360 Assembly

*        Tokenize a string -       08/06/2018
TOKSTR   CSECT
         USING  TOKSTR,R13         base register
         B      72(R15)            skip savearea
         DC     17F'0'             savearea
         SAVE   (14,12)            save previous context
         ST     R13,4(R15)         link backward
         ST     R15,8(R13)         link forward
         LR     R13,R15            set addressability
         MVC    N,=A(1)            n=1
         LA     R7,1               i1=1
         LA     R6,1               i=1
       DO WHILE=(C,R6,LE,LENS)     do i=1 to length(s);
         LA     R4,S-1             @s-1
         AR     R4,R6              +i
         MVC    C,0(R4)            c=substr(s,i,1)
       IF CLI,C,EQ,C',' THEN       if c=',' then do
         BAL    R14,TOK              call tok
         LR     R2,R8                i2
         SR     R2,R7                i2-i1
         LA     R2,1(R2)             i2-i1+1
         L      R1,N                 n
         SLA    R1,1                 *2
         STH    R2,TALEN-2(R1)       talen(n)=i2-i1+1
         L      R2,N                 n
         LA     R2,1(R2)             n+1
         ST     R2,N                 n=n+1
         LA     R7,1(R6)             i1=i+1
       ENDIF    ,                    endif 
         LA     R6,1(R6)             i++
       ENDDO    ,                  enddo i
         BAL    R14,TOK            call tok
         LR     R2,R8              i2
         SR     R2,R7              i2-i1
         LA     R2,1(R2)           i2-i1+1
         L      R1,N               n
         SLA    R1,1               *2
         STH    R2,TALEN-2(R1)     talen(n)=i2-i1+1
         LA     R11,PG             pgi=@pg
         LA     R6,1               i=1
       DO WHILE=(C,R6,LE,N)        do i=1 to n
         LR     R1,R6                i
         SLA    R1,1                 *2
         LH     R10,TALEN-2(R1)      l=talen(i)
         LR     R1,R6                i
         SLA    R1,3                 *8
         LA     R4,TABLE-8(R1)       @table(i)
         LR     R2,R10               l
         BCTR   R2,0                 ~
         EX     R2,MVCX              output table(i) length(l)
         AR     R11,R10              pgi=pgi+l
       IF C,R6,NE,N THEN             if i^=n then 
         MVC    0(1,R11),=C'.'         output '.'
         LA     R11,1(R11)             pgi=pgi+1
       ENDIF    ,                    endif 
         LA     R6,1(R6)             i++
       ENDDO    ,                  enddo i
         XPRNT  PG,L'PG            print
         L      R13,4(0,R13)       restore previous savearea pointer
         RETURN (14,12),RC=0       restore registers from calling sav
TOK      LR     R5,R6              i                              <--
         BCTR   R5,0               i-1                              |
         LR     R8,R5              i2=i-1
         SR     R5,R7              i2-i1
         LA     R5,1(R5)           l=i2-i1+1  source length
         L      R1,N               n
         SLA    R1,3               *8
         LA     R2,TABLE-8(R1)     @table(n)
         LA     R4,S-1             @s-1
         AR     R4,R7              @s+i1-1
         LA     R3,8               target length
         MVCL   R2,R4              table(n)=substr(s,i1,i2-i1+1)    |
         BR     R14                End TOK subroutine             <--
MVCX     MVC    0(0,R11),0(R4)     output table(i)
S        DC     CL80'Hello,How,Are,You,Today'  <== input string ==
LENS     DC     F'23'              length(s)   <==
TABLE    DC     8CL8' '            table(8)
TALEN    DC     8H'0'              talen(8) 
C        DS     CL1                char
N        DS     F                  number of tokens
PG       DC     CL80' '            buffer
         YREGS
         END    TOKSTR
Output:
Hello.How.Are.You.Today

8080 Assembly

puts:	equ	9
	org	100h
	jmp	demo
	;;;	Split the string at DE by the character in C.
	;;;	Store pointers to the beginning of the elements starting at HL
	;;;	The amount of elements is returned in B.
split:	mvi	b,0		; Amount of elements
sloop:	mov	m,e		; Store pointer at [HL]
	inx	h
	mov	m,d
	inx	h
	inr	b		; Increment counter
sscan:	ldax	d		; Get current character
	inx	d
	cpi	'$'		; Done?
	rz			; Then stop
	cmp	c		; Place to split?
	jnz	sscan		; If not, keep going
	dcx	d
	mvi	a,'$'		; End the string here
	stax	d
	inx	d
	jmp	sloop		; Next part
	;;;	Test on the string given in the task
demo:	lxi	h,parts		; Parts array
	lxi	d,hello		; String
	mvi	c,','
	call 	split		; Split the string
	lxi	h,parts		; Print each part
loop:	mov	e,m		; Load pointer into DE
	inx	h
	mov	d,m
	inx	h
	push	h		; Keep the array pointer
	push	b		; And the counter
	mvi	c,puts 		; Print the string
	call	5
	lxi	d,period	; And a period
	mvi	c,puts
	call 	5
	pop 	b		; Restore the counter
	pop 	h		; Restore the array pointer
	dcr	b 		; One fewer string left
	jnz 	loop
	ret 
period:	db	'. $'
hello:	db	'Hello,How,Are,You,Today$'
parts:	equ	$
Output:
Hello. How. Are. You. Today.

8086 Assembly

	cpu	8086
	org	100h
section	.text
	jmp	demo
	;;;	Split the string at DS:SI on the character in DL.
	;;;	Store pointers to strings starting at ES:DI.
	;;;	The amount of strings is returned in CX.
split:	xor	cx,cx		; Zero out counter
.loop:	mov	ax,si		; Store pointer to current location
	stosw
	inc	cx		; Increment counter
.scan:	lodsb			; Get byte
	cmp	al,'$'		; End of string?
	je	.done
	cmp	al,dl		; Character to split on?
	jne	.scan
	mov	[si-1],byte '$'	; Terminate string
	jmp	.loop
.done:	ret
	;;;	Test on the string given in the task
demo:	mov	si,hello	; String to split
	mov	di,parts	; Place to store pointers
	mov	dl,','		; Character to split string on
	call	split
	;;;	Print the resulting strings, and periods
	mov	si,parts	; Array of string pointers 
print:	lodsw			; Load next pointer
	mov	dx,ax		; Print string using DOS
	mov	ah,9
	int	21h
	mov	dx,period	; Then print a period
	int	21h
	loop	print		; Loop while there are strings
	ret 
section .data
period:	db	'. $'
hello:	db	'Hello,How,Are,You,Today$'
section	.bss
parts:	resw	10
Output:
Hello. How. Are. You. Today. 

AArch64 Assembly

Works with: as version Raspberry Pi 3B version Buster 64 bits
/* ARM assembly AARCH64 Raspberry PI 3B */
/*  program strTokenize64.s   */

/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
 
.equ NBPOSTESECLAT,          20

/*******************************************/
/* Initialized data                        */
/*******************************************/
.data
szMessFinal:         .asciz "Words are : \n"
 
szString:            .asciz "Hello,How,Are,You,Today"
szMessError:         .asciz "Error tokenize !!\n"
szCarriageReturn:    .asciz "\n"
/*******************************************/
/* UnInitialized data                      */
/*******************************************/
.bss 
/*******************************************/
/*  code section                           */
/*******************************************/
.text
.global main 
main: 
    ldr x0,qAdrszString                           // string address 
    mov x1,','                                    // separator
    bl stTokenize
    cmp x0,-1                                     // error ?
    beq 99f
    mov x2,x0                                     // table address
    ldr x0,qAdrszMessFinal                        // display message
    bl affichageMess
    ldr x4,[x2]                                   // number of areas
    add x2,x2,8                                   // first area
    mov x3,0                                      // loop counter
    mov x0,x2
1:                                                // display loop 
    ldr x0,[x2,x3, lsl 3]                         // address area
    bl affichageMess
    ldr x0,qAdrszCarriageReturn                   // display carriage return
    bl affichageMess
    add x3,x3,1                                  // counter + 1
    cmp x3,x4                                     // end ?
    blt 1b                                        // no -> loop
 
    b 100f
99:                                               // display error message
    ldr x0,qAdrszMessError
    bl affichageMess
 
100:                                              // standard end of the program
    mov x0,0                                       // return code
    mov x8,EXIT                                   // request to exit program
    svc 0                                         // perform the system call
qAdrszString:             .quad szString
//qAdrszFinalString:        .quad szFinalString
qAdrszMessFinal:          .quad szMessFinal
qAdrszMessError:          .quad szMessError
qAdrszCarriageReturn:     .quad szCarriageReturn

/*******************************************************************/	   
/* Separate string by separator into an array                     */
/* areas are store on the heap Linux                               */
/*******************************************************************/	  
/* x0 contains string address */
/* x1 contains separator character (, or . or : )    */
/* x0 returns table address with first item = number areas */
/* and other items contains pointer of each string     */
stTokenize:
    stp x1,lr,[sp,-16]!           // save  registers
    mov x16,x0
    mov x9,x1                     // save separator
    mov x14,0          
1:                                // compute length string for place reservation on the heap
    ldrb w12,[x0,x14]
    cbz x12, 2f
    add x14,x14,1
    b 1b
2:
    ldr x12,qTailleTable
    add x15,x12,x14
    and x15,x15,0xFFFFFFFFFFFFFFF0
    add x15,x15,16                 // align word on the heap
                                  // place reservation on the heap 
    mov x0,0                      // heap address
    mov x8,BRK                    // call system linux 'brk'
    svc 0                         // call system
    cmp x0,-1                     // error call system
    beq 100f
    mov x14,x0                    // save address  heap begin = begin array
    add x0,x0,x15                 // reserve x15 byte on the heap
    mov x8,BRK                    // call system linux 'brk'
    svc 0
    cmp x0,-1
    beq 100f
                                  // string copy on the heap
    add x13,x14,x12               // behind the array 
    mov x0,x16
    mov x1,x13
3:                                // loop copy string
    ldrb w12,[x0],1               // read one byte and increment pointer one byte
    strb w12,[x1],1               // store one byte and increment pointer one byte
    cbnz x12,3b                   // end of string ? no -> loop 
 
    mov x0,#0
    str x0,[x14]
    str x13,[x14,8]
    mov x12,#1                     // areas counter
4:                                // loop load string character 
    ldrb w0,[x13]
    cbz x0,5f                     // end string 
    cmp x0,x9                     // separator ?
    cinc x13,x13,ne               // no -> next location 
    bne 4b                        // and loop
    strb wzr,[x13]                // store zero final of string
    add x13,x13,1                 // next character
    add x12,x12,1                 // areas counter + 1
    str x13,[x14,x12, lsl #3]     // store address area in the table at index x2
    b 4b                          // and loop
 
5:
    str x12,[x14]                 // store number areas
    mov x0,x14                    // returns array address
100:
    ldp x1,lr,[sp],16             // restaur  2 registers
    ret                           // return to address lr x30
qTailleTable:      .quad 8 * NBPOSTESECLAT

/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
Output:
Words are :
Hello
How
Are
You
Today

ACL2

(defun split-at (xs delim)
   (if (or (endp xs) (eql (first xs) delim))
       (mv nil (rest xs))
       (mv-let (before after)
               (split-at (rest xs) delim)
          (mv (cons (first xs) before) after))))

(defun split (xs delim)
   (if (endp xs)
       nil
       (mv-let (before after)
               (split-at xs delim)
          (cons before (split after delim)))))

(defun css->strs (css)
   (if (endp css)
       nil
       (cons (coerce (first css) 'string)
             (css->strs (rest css)))))

(defun split-str (str delim)
   (css->strs (split (coerce str 'list) delim)))

(defun print-with (strs delim)
   (if (endp strs)
       (cw "~%")
       (progn$ (cw (first strs))
               (cw (coerce (list delim) 'string))
               (print-with (rest strs) delim))))
Output:
> (print-with (split-str "Hello,How,Are,You,Today" #\,) #\.)
Hello.How.Are.You.Today.

Action!

The user must type in the monitor the following command after compilation and before running the program!

SET EndProg=*
CARD EndProg ;required for ALLOCATE.ACT

INCLUDE "D2:ALLOCATE.ACT" ;from the Action! Tool Kit. You must type 'SET EndProg=*' from the monitor after compiling, but before running this program!

DEFINE PTR="CARD"

BYTE FUNC Split(CHAR ARRAY s CHAR c PTR ARRAY items)
  BYTE i,count,start,len
  CHAR ARRAY item

  IF s(0)=0 THEN RETURN (0) FI

  i=1 count=0
  WHILE i<s(0)
  DO
    start=i
    WHILE i<=s(0) AND s(i)#c
    DO
      i==+1
    OD
    len=i-start
    item=Alloc(len+1)
    SCopyS(item,s,start,i-1)
    items(count)=item
    count==+1
    i==+1
  OD
RETURN (count)

PROC Join(PTR ARRAY items BYTE count CHAR c CHAR ARRAY s)
  BYTE i,pos
  CHAR POINTER srcPtr,dstPtr
  CHAR ARRAY item

  s(0)=0
  IF count=0 THEN RETURN FI

  pos=1
  FOR i=0 TO count-1
  DO
    item=items(i)
    srcPtr=item+1
    dstPtr=s+pos
    MoveBlock(dstPtr,srcPtr,item(0))
    pos==+item(0)
    IF i<count-1 THEN
      s(pos)='.
      pos==+1
    FI
  OD
  s(0)=pos-1
RETURN

PROC Clear(PTR ARRAY items BYTE POINTER count)
  BYTE i
  CHAR ARRAY item

  IF count^=0 THEN RETURN FI

  FOR i=0 TO count^-1
  DO
    item=items(i)
    Free(item,item(0)+1)
  OD
  count^=0
RETURN

PROC Main()
  CHAR ARRAY s="Hello,How,Are,You,Today"
  CHAR ARRAY r(256)
  PTR ARRAY items(100)
  BYTE i,count

  Put(125) PutE() ;clear screen
  
  AllocInit(0)
  count=Split(s,',,items)
  Join(items,count,'.,r)

  PrintF("Input:%E""%S""%E%E",s)
  PrintE("Split:")
  FOR i=0 TO count-1
  DO
    PrintF("""%S""",items(i))
    IF i<count-1 THEN
      Print(", ")
    ELSE
      PutE() PutE()
    FI
  OD
  PrintF("Join:%E""%S""%E",r)
  
  Clear(items,@count)
RETURN
Output:

Screenshot from Atari 8-bit computer

Input:
"Hello,How,Are,You,Today"

Split:
"Hello", "How", "Are", "You", "Today"

Join:
"Hello.How.Are.You.Today"

ActionScript

var hello:String = "Hello,How,Are,You,Today";
var tokens:Array = hello.split(",");
trace(tokens.join("."));

// Or as a one-liner
trace("Hello,How,Are,You,Today".split(",").join("."));

Ada

with Ada.Text_IO, Ada.Containers.Indefinite_Vectors, Ada.Strings.Fixed, Ada.Strings.Maps;
use Ada.Text_IO, Ada.Containers, Ada.Strings, Ada.Strings.Fixed, Ada.Strings.Maps;

procedure Tokenize is
   package String_Vectors is new Indefinite_Vectors (Positive, String);
   use String_Vectors;
   Input  : String   := "Hello,How,Are,You,Today";
   Start  : Positive := Input'First;
   Finish : Natural  := 0;
   Output : Vector   := Empty_Vector;
begin
   while Start <= Input'Last loop
      Find_Token (Input, To_Set (','), Start, Outside, Start, Finish);
      exit when Start > Finish;
      Output.Append (Input (Start .. Finish));
      Start := Finish + 1;
   end loop;
   for S of Output loop
      Put (S & ".");
   end loop;
end Tokenize;

ALGOL 68

main:(

  OP +:=  = (REF FLEX[]STRING in out, STRING item)VOID:(
    [LWB in out: UPB in out+1]STRING new;
    new[LWB in out: UPB in out]:=in out;
    new[UPB new]:=item;
    in out := new
  );

  PROC string split = (REF STRING beetles, STRING substr)[]STRING:(
    """ Split beetles where substr is found """;
    FLEX[1:0]STRING out;
    INT start := 1, pos;
    WHILE string in string(substr, pos, beetles[start:]) DO
      out +:= STRING(beetles[start:start+pos-2]);
      start +:= pos + UPB substr - 1
    OD;
    IF start > LWB beetles THEN
      out +:= STRING(beetles[start:])
    FI;
    out
  );

  PROC char split = (REF STRING beetles, STRING chars)[]STRING: (
    """ Split beetles where character is found in chars """;
    FLEX[1:0]STRING out;
    FILE beetlef;
    associate(beetlef, beetles); # associate a FILE handle with a STRING   #
    make term(beetlef, chars);   # make term: assign CSV string terminator # 

    PROC raise logical file end = (REF FILE f)BOOL: except logical file end;
    on logical file end(beetlef, raise logical file end);

    STRING solo;
    DO
      getf(beetlef, ($g$, solo));
      out+:=solo;
      getf(beetlef, ($x$)) # skip CHAR separator #
    OD;
    except logical file end:
      SKIP;
    out
  );

  STRING beetles := "John Lennon, Paul McCartney, George Harrison, Ringo Starr";

  printf(($g"."$, string split(beetles, ", "),$l$));
  printf(($g"."$, char   split(beetles, ", "),$l$))
)
Output:
 John Lennon.Paul McCartney.George Harrison.Ringo Starr.
 John.Lennon..Paul.McCartney..George.Harrison..Ringo.Starr.

Amazing Hopper

Hopper provides instructions for separating and modifying tokens from a string. Let "s" be a string; "n" token number:

1) {n}, $(s) ==> gets token "n" from string "s".

2) {"word", n} $$(s) ==> replace token "n" of "s", with "word".

Note: the "splitnumber" macro cannot separate a number converted to a string by the "XTOSTR" function, because this function "rounds" the number to the decimal position by default.

#include <hopper.h>

#proto splitdate(_DATETIME_)
#proto splitnumber(_N_)
#proto split(_S_,_T_)

main:
    
    s="this string will be separated into parts with space token separator"
    
    aS=0,let( aS :=_split(s," "))
    
    {","}toksep                     // set a new token separator
    {"String: ",s}
    {"\nArray:\n",aS},
    {"\nSize="}size(aS),println     // "size" return an array: {dims,#rows,#cols,#pages}
    
    {"\nOriginal number: ",-125.489922},println
    w=0,let(w:=_split number(-125.489922) )
    {"Integer part: "}[1]get(w)              // get first element from array "w"
    {"\nDecimal part: "}[2]get(w),println    // get second element from array "w"
    
    {"\nDate by DATENOW(TODAY) macro: "},print
    dt=0, let( dt :=_splitdate(datenow(TODAY);!puts))  // "!" keep first element from stack
    {"\nDate: "}[1]get(dt)
    {"\nTime: "}[2]get(dt),println

exit(0)

.locals
splitdate(_DATETIME_)
    _SEP_=0,gettoksep,mov(_SEP_)      // "gettoksep" return actual token separator
    {","}toksep,                      // set a new token separator
    _NEWARRAY_={}
    {1},$( _DATETIME_ ),
    {2},$( _DATETIME_ ),pushall(_NEWARRAY_)
    {_SEP_}toksep                     // restore ols token separator   
   {_NEWARRAY_}
back

splitnumber(_X_)      
   part_int=0,part_dec=0,
   {_X_},!trunc,mov(part_int),
   minus(part_int), !sign,mul
   xtostr,mov(part_dec), part_dec+=2, // "part_dec+=2", delete "0." from "part_dec"
   {part_dec}xtonum,mov(part_dec)
   _NEWARRAY_={},{part_int,part_dec},pushall(_NEWARRAY_)
   {_NEWARRAY_}
back

split(_S_,_T_)
    _NEWARRAY_={},_VAR1_=0,_SEP_=0,gettoksep,mov(_SEP_)
   {_T_}toksep,totaltoken(_S_), 
   mov(_VAR1_),                      // for total tokens
   _VAR2_=1,                         // for real position of tokens into the string
   ___SPLIT_ITER:
       {_VAR2_}$( _S_ ),push(_NEWARRAY_)
       ++_VAR2_,--_VAR1_
       { _VAR1_ },jnz(___SPLIT_ITER) // jump to "___SPLIT_ITER" if "_VAR1_" is not zero.
   clear(_VAR2_),clear(_VAR1_)
   {_SEP_}toksep
   {_NEWARRAY_}
back
Output:
Output:

   String: this string will be separated into parts with space token separator
   Array:
   this,string,will,be,separated,into,parts,with,space,token,separator
   Size=1,11

   Original number: -125.49
   Integer part: -125
   Decimal part: 489922

   Date by DATENOW(TODAY) macro: 22/11/2021,18:41:20:13
   Date: 22/11/2021
   Time: 18:41:20:13

APL

     '.',⍨¨ ','(≠⊆⊢)'abc,123,X'   ⍝ [1] Do the split: ','(≠⊆⊢)'abc,123,X'; [2] append the periods: '.',⍨¨ 
 abc.  123.  X.                   ⍝ 3 strings (char vectors), each with a period at the end.

AppleScript

on run
  intercalate(".", splitOn(",", "Hello,How,Are,You,Today"))
end run
 
 
-- splitOn :: String -> String -> [String]
on splitOn(strDelim, strMain)
  set {dlm, my text item delimiters} to {my text item delimiters, strDelim}
  set lstParts to text items of strMain
  set my text item delimiters to dlm
  return lstParts
end splitOn
 
-- intercalate :: String -> [String] -> String
on intercalate(strText, lstText)
  set {dlm, my text item delimiters} to {my text item delimiters, strText}
  set strJoined to lstText as text
  set my text item delimiters to dlm
  return strJoined
end intercalate
Output:
Hello.How.Are.You.Today

Or,

set my text item delimiters to ","
set tokens to the text items of "Hello,How,Are,You,Today"

set my text item delimiters to "."
log tokens as text
Output:
Hello.How.Are.You.Today

ARM Assembly

Works with: as version Raspberry Pi
/* ARM assembly Raspberry PI  */
/*  program strTokenize.s   */

/* Constantes    */
.equ STDOUT, 1                          @ Linux output console
.equ EXIT,   1                           @ Linux syscall
.equ WRITE,  4                           @ Linux syscall

.equ NBPOSTESECLAT,          20

/* Initialized data */
.data
szMessFinal:   .asciz "Words are : \n"

szString:            .asciz "Hello,How,Are,You,Today"
szMessError:         .asciz "Error tokenize !!\n"
szCarriageReturn:   .asciz "\n"

/* UnInitialized data */
.bss 

/*  code section */
.text
.global main 
main: 
    ldr r0,iAdrszString                           @ string address 
    mov r1,#','                                   @ separator
    bl stTokenize
    cmp r0,#-1                                    @ error ?
    beq 99f
    mov r2,r0                                     @ table address
    ldr r0,iAdrszMessFinal                        @ display message
    bl affichageMess
    ldr r4,[r2]                                   @ number of areas
    add r2,#4                                     @ first area
    mov r3,#0                                     @ loop counter
1:                                                @ display loop 
    ldr r0,[r2,r3, lsl #2]                        @ address area
    bl affichageMess
    ldr r0,iAdrszCarriageReturn                   @ display carriage return
    bl affichageMess
    add r3,#1                                     @ counter + 1
    cmp r3,r4                                     @ end ?
    blt 1b                                        @ no -> loop

    b 100f
99:                                               @ display error message
    ldr r0,iAdrszMessError
    bl affichageMess

100:                                              @ standard end of the program
    mov r0, #0                                    @ return code
    mov r7, #EXIT                                 @ request to exit program
    svc 0                                         @ perform the system call
iAdrszString:             .int szString
iAdrszFinalString:       .int szFinalString
iAdrszMessFinal:          .int szMessFinal
iAdrszMessError:          .int szMessError
iAdrszCarriageReturn:    .int szCarriageReturn
/******************************************************************/
/*     display text with size calculation                         */ 
/******************************************************************/
/* r0 contains the address of the message */
affichageMess:
    push {r0,r1,r2,r7,lr}                       @ save  registers 
    mov r2,#0                                   @ counter length */
1:                                              @ loop length calculation
    ldrb r1,[r0,r2]                             @ read octet start position + index 
    cmp r1,#0                                   @ if 0 its over
    addne r2,r2,#1                              @ else add 1 in the length
    bne 1b                                      @ and loop 
                                                @ so here r2 contains the length of the message 
    mov r1,r0                                   @ address message in r1 
    mov r0,#STDOUT                              @ code to write to the standard output Linux
    mov r7, #WRITE                              @ code call system "write" 
    svc #0                                      @ call systeme
    pop {r0,r1,r2,r7,lr}                        @ restaur des  2 registres
    bx lr                                       @ return
/*******************************************************************/	   
/* Separate string by separator into an array                     */
/* areas are store on the heap Linux                               */
/*******************************************************************/	  
/* r0 contains string address */
/* r1 contains separator character (, or . or : )    */
/* r0 returns table address with first item = number areas */
/* and other items contains pointer of each string     */
stTokenize:
    push {r1-r8,lr}                                 @ save des registres
    mov r6,r0
    mov r8,r1                                       @ save separator
    bl strLength                                    @ length string for place reservation on the heap
    mov r4,r0
    ldr r5,iTailleTable
    add r5,r0
    and r5,#0xFFFFFFFC
    add r5,#4                                       @ align word on the heap
                                                    @ place reservation on the heap 
    mov r0,#0                                       @ heap address
    mov r7, #0x2D                                   @ call system linux 'brk'
    svc #0                                          @ call system
    cmp r0,#-1                                      @ error call system
    beq 100f
    mov r3,r0                                       @ save address  heap begin
    add r0,r5                                       @ reserve r5 byte on the heap
    mov r7, #0x2D                                   @ call system linux 'brk'
    svc #0
    cmp r0,#-1
    beq 100f
                                                    @ string copy on the heap
    mov r0,r6
    mov r1,r3
1:                                                  @ loop copy string
    ldrb r2,[r0],#1                                 @ read one byte and increment pointer one byte
    strb r2,[r1],#1                                 @ store one byte and increment pointer one byte
    cmp r2,#0                                       @ end of string ?
    bne 1b                                          @ no -> loop 

    add r4,r3                                        @ r4 contains address table begin
    mov r0,#0
    str r0,[r4]
    str r3,[r4,#4]
    mov r2,#1                                       @ areas counter
2:                                                  @ loop load string character 
    ldrb r0,[r3]
    cmp r0,#0
    beq 3f                                          @ end string 
    cmp r0,r8                                       @ separator ?
    addne r3,#1                                     @ no -> next location 
    bne 2b                                          @ and loop
    mov r0,#0                                       @ store zero final of string
    strb r0,[r3]
    add r3,#1                                       @ next character
    add r2,#1                                       @ areas counter + 1
    str r3,[r4,r2, lsl #2]                          @ store address area in the table at index r2
    b 2b                                            @ and loop
 
3:
    str r2,[r4]                                     @ returns number areas
    mov r0,r4
100:
    pop {r1-r8,lr}
    bx lr
iTailleTable: .int 4 * NBPOSTESECLAT
/***************************************************/
/*   calcul size string                            */
/***************************************************/
/* r0 string address                 */
/* r0 returns size string            */
strLength:
    push {r1,r2,lr}
    mov r1,#0                                           @ init counter
1:
   ldrb r2,[r0,r1]                                      @ load byte of string index r1
   cmp r2,#0                                            @ end string ?
   addne r1,#1                                          @ no -> +1 counter
   bne 1b                                               @ and loop

100:
    mov r0,r1
    pop {r1,r2,lr}
    bx lr

Arturo

str: "Hello,How,Are,You,Today"

print join.with:"." split.by:"," str
Output:
Hello.How.Are.You.Today

Astro

let text = 'Hello,How,Are,You,Today'
let tokens = text.split(||,||)
print tokens.join(with: '.')

AutoHotkey

string := "Hello,How,Are,You,Today"
stringsplit, string, string, `,
loop, % string0
{
msgbox % string%A_Index%
}

AWK

BEGIN {
  s = "Hello,How,Are,You,Today"
  split(s, arr, ",")
  for(i=1; i < length(arr); i++) {
    printf arr[i] "."
  }
  print
}

A more idiomatic way for AWK is

BEGIN { FS = "," }
{
  for(i=1; i <= NF; i++) printf $i ".";
  print ""
}

which "tokenize" each line of input and this is achieved by using "," as field separator

BASIC

Applesoft BASIC

100 T$ = "HELLO,HOW,ARE,YOU,TODAY"
110 GOSUB 200"TOKENIZE
120 FOR I = 1 TO N
130     PRINT A$(I) "." ;
140 NEXT
150 PRINT
160 END

200 IF N = 0 THEN DIM A$(256)
210 N = 1
220 A$(N) = "
230 FOR TI = 1 TO LEN(T$)
240     C$ = MID$(T$, TI, 1)
250     T = C$ = ","
260     IF T THEN C$ = "
270     N = N + T
280     IF T THEN A$(N) = C$
290     A$(N) = A$(N) + C$
300 NEXT TI
310 RETURN

BaCon

BaCon includes extensive support for delimited strings.

OPTION BASE 1

string$ = "Hello,How,Are,You,Today"

' Tokenize a string into an array
SPLIT string$ BY "," TO array$

' Print array elements with new delimiter
PRINT COIL$(i, UBOUND(array$), array$[i], ".")

' Or simply replace the delimiter
PRINT DELIM$(string$, ",", ".")
Output:
prompt$ ./tokenize
Hello.How.Are.You.Today
Hello.How.Are.You.Today

BASIC256

instring$ = "Hello,How,Are,You,Today"

tokens$ = explode(instring$,",")
for i = 0 to tokens$[?]-1
	print tokens$[i]; ".";
next i
end


BBC BASIC

      INSTALL @lib$+"STRINGLIB"
      
      text$ = "Hello,How,Are,You,Today"
      n% = FN_split(text$, ",", array$())
      FOR i% = 0 TO n%-1
        PRINT array$(i%) "." ;
      NEXT
      PRINT

Chipmunk Basic

Solutions Applesoft BASIC and Commodore BASIC work without changes.

Commodore BASIC

Based on the AppleSoft BASIC version.

10 REM TOKENIZE A STRING ... ROSETTACODE.ORG
20 T$ = "HELLO,HOW,ARE,YOU,TODAY"
30 GOSUB 200, TOKENIZE
40 FOR I = 1 TO N
50     PRINT A$(I) "." ;
60 NEXT
70 PRINT
80 END
200 IF N = 0 THEN DIM A$(256)
210 N = 1
220 A$(N) = ""
230 FOR L = 1 TO LEN(T$)
240     C$ = MID$(T$, L, 1)
250     IF C$<>"," THEN A$(N) = A$(N) + C$: GOTO 270
260     N = N + 1
270 NEXT L
280 RETURN

FreeBASIC

sub tokenize( instring as string, tokens() as string, sep as string )
    redim tokens(0 to 0) as string
    dim as string*1 ch
    dim as uinteger t=0
    for i as uinteger = 1 to len(instring)
        ch = mid(instring,i,1)
        if ch = sep then
            t = t + 1
            redim preserve tokens(0 to t)
        else
            tokens(t) = tokens(t) + ch
        end if
    next i
    return
end sub

dim as string instring = "Hello,How,Are,You,Today"
redim as string tokens(-1)
tokenize( instring, tokens(), "," )
for i as uinteger = 0 to ubound(tokens)
   print tokens(i);".";
next i

Liberty BASIC

'Note that Liberty Basic's array usage can reach element #10 before having to DIM the array
For i = 0 To 4
    array$(i) = Word$("Hello,How,Are,You,Today", (i + 1), ",")
    array$ = array$ + array$(i) + "."
Next i

Print Left$(array$, (Len(array$) - 1))

MSX Basic

The Commodore BASIC solution works without any changes.

PowerBASIC

PowerBASIC has a few keywords that make parsing strings trivial: PARSE, PARSE$, and PARSECOUNT. (PARSE$, not shown here, is for extracting tokens one at a time, while PARSE extracts all tokens at once into an array. PARSECOUNT returns the number of tokens found.)

FUNCTION PBMAIN () AS LONG
    DIM parseMe AS STRING
    parseMe = "Hello,How,Are,You,Today"

    REDIM parsed(PARSECOUNT(parseMe) - 1) AS STRING
    PARSE parseMe, parsed()  'comma is default delimiter

    DIM L0 AS LONG, outP AS STRING
    outP = parsed(0)
    FOR L0 = 1 TO UBOUND(parsed)  'could reuse parsecount instead of ubound
        outP = outP & "." & parsed(L0)
    NEXT

    MSGBOX outP
END FUNCTION

PureBasic

As described

NewList MyStrings.s()

For i=1 To 5
  AddElement(MyStrings())
  MyStrings()=StringField("Hello,How,Are,You,Today",i,",")
Next i

ForEach MyStrings()
  Print(MyStrings()+".")
Next

Still, easier would be

Print(ReplaceString("Hello,How,Are,You,Today",",","."))

QBasic

DIM parseMe AS STRING
parseMe = "Hello,How,Are,You,Today"

DIM tmpLng1 AS INTEGER, tmpLng2 AS INTEGER, parsedCount AS INTEGER
tmpLng2 = 1
parsedCount = -1

'count number of tokens
DO
    tmpLng1 = INSTR(tmpLng2, parseMe, ",")
    IF tmpLng1 THEN
        parsedCount = parsedCount + 1
        tmpLng2 = tmpLng1 + 1
    ELSE
        IF tmpLng2 < (LEN(parseMe) + 1) THEN parsedCount = parsedCount + 1
        EXIT DO
    END IF
LOOP

IF parsedCount > -1 THEN
    REDIM parsed(parsedCount) AS STRING
    tmpLng2 = 1
    parsedCount = -1

    'parse
    DO
        tmpLng1 = INSTR(tmpLng2, parseMe, ",")
        IF tmpLng1 THEN
            parsedCount = parsedCount + 1
            parsed(parsedCount) = MID$(parseMe, tmpLng2, tmpLng1 - tmpLng2)
            tmpLng2 = tmpLng1 + 1
        ELSE
            IF tmpLng2 < (LEN(parseMe) + 1) THEN
                parsedCount = parsedCount + 1
                parsed(parsedCount) = MID$(parseMe, tmpLng2)
            END IF
            EXIT DO
        END IF
    LOOP

    PRINT parsed(0);
    FOR L0 = 1 TO parsedCount
        PRINT "."; parsed(L0);
    NEXT
END IF

Run BASIC

text$ = "Hello,How,Are,You,Today"
FOR i = 1 to 5
 textArray$(i) = word$(text$,i,",")
 print textArray$(i);" ";
NEXT

VBScript

One liner

WScript.Echo Join(Split("Hello,How,Are,You,Today", ","), ".")

In fact, the Visual Basic solution (below) could have done the same, as Join() is available.

Visual Basic

Translation of: PowerBASIC

Unlike PowerBASIC, there is no need to know beforehand how many tokens are in the string -- Split automagically builds the array for you.

Sub Main()
    Dim parseMe As String, parsed As Variant
    parseMe = "Hello,How,Are,You,Today"

    parsed = Split(parseMe, ",")

    Dim L0 As Long, outP As String
    outP = parsed(0)
    For L0 = 1 To UBound(parsed)
        outP = outP & "." & parsed(L0)
    Next

    MsgBox outP
End Sub

Batch File

@echo off
setlocal enabledelayedexpansion
call :tokenize %1 res
echo %res%
goto :eof

:tokenize
set str=%~1
:loop
for %%i in (%str%) do set %2=!%2!.%%i
set %2=!%2:~1!
goto :eof

Demo

>tokenize.cmd "Hello,How,Are,You,Today"
Hello.How.Are.You.Today

BQN

Uses a splitting idiom from bqncrate.

Split  (+`׬)-=  

'.'´ ',' Split "Hello,How,Are,You,Today"
Output:
"Hello.How.Are.You.Today"

Bracmat

Solution that employs string pattern matching to spot the commas

( "Hello,How,Are,You,Today":?String
& :?ReverseList
&   whl
  ' ( @(!String:?element "," ?String)
    & !element !ReverseList:?ReverseList
    )
& !String:?List
&   whl
  ' ( !ReverseList:%?element ?ReverseList
    & (!element.!List):?List
    )
& out$!List
)

Solution that starts by evaluating the input and employs the circumstance that the comma is a list constructing binary operator and that the string does not contain any other characters that are interpreted as operators on evaluation.

(  get$("Hello,How,Are,You,Today",MEM):?CommaseparatedList
& :?ReverseList
&   whl
  ' ( !CommaseparatedList:(?element,?CommaseparatedList)
    & !element !ReverseList:?ReverseList
    )
& !CommaseparatedList:?List
&   whl
  ' ( !ReverseList:%?element ?ReverseList
    & (!element.!List):?List
    )
& out$!List
)

C

Works with: ANSI C
Library: POSIX

This example uses the strtok() function to separate the tokens. This function is destructive (replacing token separators with '\0'), so we have to make a copy of the string (using strdup()) before tokenizing. strdup() is not part of ANSI C, but is available on most platforms. It can easily be implemented with a combination of strlen(), malloc(), and strcpy().

#include<string.h>
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	char *a[5];
	const char *s="Hello,How,Are,You,Today";
	int n=0, nn;

	char *ds=strdup(s);

	a[n]=strtok(ds, ",");
	while(a[n] && n<4) a[++n]=strtok(NULL, ",");

	for(nn=0; nn<=n; ++nn) printf("%s.", a[nn]);
	putchar('\n');

	free(ds);

	return 0;
}

Another way to accomplish the task without the built-in string functions is to temporarily modify the separator character. This method does not need any additional memory, but requires the input string to be writeable.

#include<stdio.h>

typedef void (*callbackfunc)(const char *);

void doprint(const char *s) {
	printf("%s.", s);
}

void tokenize(char *s, char delim, callbackfunc cb) {
	char *olds = s;
	char olddelim = delim;
	while(olddelim && *s) {
		while(*s && (delim != *s)) s++;
		*s ^= olddelim = *s; // olddelim = *s; *s = 0;
		cb(olds);
		*s++ ^= olddelim; // *s = olddelim; s++;
		olds = s;
	}
}

int main(void)
{
        char array[] = "Hello,How,Are,You,Today";
	tokenize(array, ',', doprint);
	return 0;
}

C#

string str = "Hello,How,Are,You,Today"; 
// or Regex.Split ( "Hello,How,Are,You,Today", "," );
// (Regex is in System.Text.RegularExpressions namespace)
string[] strings = str.Split(',');
Console.WriteLine(String.Join(".", strings));

C++

Works with: C++98

std::getline() is typically used to tokenize strings on a single-character delimiter

#include <string>
#include <sstream>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
int main()
{
    std::string s = "Hello,How,Are,You,Today";
    std::vector<std::string> v;
    std::istringstream buf(s);
    for(std::string token; getline(buf, token, ','); )
        v.push_back(token);
    copy(v.begin(), v.end(), std::ostream_iterator<std::string>(std::cout, "."));
    std::cout << '\n';
}
Works with: C++98

C++ allows the user to redefine what is considered whitespace. If the delimiter is whitespace, tokenization becomes effortless.

#include <string>
#include <locale>
#include <sstream>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
struct comma_ws : std::ctype<char> {
    static const mask* make_table() {
    static std::vector<mask> v(classic_table(), classic_table() + table_size);
        v[','] |= space;  // comma will be classified as whitespace
        return &v[0];
    }
    comma_ws(std::size_t refs = 0) : ctype<char>(make_table(), false, refs) {}
};
int main()
{
    std::string s = "Hello,How,Are,You,Today";
    std::istringstream buf(s);
    buf.imbue(std::locale(buf.getloc(), new comma_ws));
    std::istream_iterator<std::string> beg(buf), end;
    std::vector<std::string> v(beg, end);
    copy(v.begin(), v.end(), std::ostream_iterator<std::string>(std::cout, "."));
    std::cout << '\n';
}
Works with: C++98
Library: boost

The boost library has multiple options for easy tokenization.

#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>
#include <boost/tokenizer.hpp>
int main()
{
    std::string s = "Hello,How,Are,You,Today";
    boost::tokenizer<> tok(s);
    std::vector<std::string> v(tok.begin(), tok.end());
    copy(v.begin(), v.end(), std::ostream_iterator<std::string>(std::cout, "."))
    std::cout << '\n';
}
Works with: C++23

C++20 and C++23 drastically improve the ergonomics of simple manipulation of ranges.

#include <string>
#include <ranges>
#include <iostream>
int main() {
    std::string s = "Hello,How,Are,You,Today";
    s = s                               // Assign the final string back to the string variable
      | std::views::split(',')          // Produce a range of the comma separated words
      | std::views::join_with('.')      // Concatenate the words into a single range of characters
      | std::ranges::to<std::string>(); // Convert the range of characters into a regular string
    std::cout << s;
}

Ceylon

Works with: Ceylon 1.2
shared void tokenizeAString() {
	value input = "Hello,How,Are,You,Today";
	value tokens = input.split(','.equals);
	print(".".join(tokens));
}

CFEngine

bundle agent main
{
  reports:
    "${with}" with => join(".", splitstring("Hello,How,Are,You,Today", ",", 99));
}
Output:
cf-agent -KIf ./tokenize-a-string.cf
R: Hello.How.Are.You.Today

See https://docs.cfengine.com/docs/master/reference-functions.html for a complete list of available functions.

Clojure

Using native Clojure functions and Java Interop:

(apply str (interpose "." (.split #"," "Hello,How,Are,You,Today")))

Using the clojure.string library:

(clojure.string/join "." (clojure.string/split "Hello,How,Are,You,Today" #","))

CLU

% This iterator splits the string on a given character,
% and returns each substring in order.
tokenize = iter (s: string, c: char) yields (string) 
    while ~string$empty(s) do
        next: int := string$indexc(c, s)
        if next = 0 then
            yield(s)
            break
        else
            yield(string$substr(s, 1, next-1)) 
            s := string$rest(s, next+1)
        end
    end
end tokenize

start_up = proc ()
    po: stream := stream$primary_output()
    str: string := "Hello,How,Are,You,Today"
    
    for part: string in tokenize(str, ',') do
        stream$putl(po, part || ".")
    end
end start_up
Output:
Hello.
How.
Are.
You.
Today.

COBOL

This can be made to handle more complex cases; UNSTRING allows multiple delimiters, capture of which delimiter was used for each field, a POINTER for starting position (set on ending), along with match TALLYING.

      identification division.
       program-id. tokenize.

       environment division.
       configuration section.
       repository.
           function all intrinsic.

       data division.
       working-storage section.
       01 period constant as ".".
       01 cmma   constant as ",".

       01 start-with.
          05 value "Hello,How,Are,You,Today".

       01 items.
          05 item pic x(6) occurs 5 times.

       procedure division.
       tokenize-main.
       unstring start-with delimited by cmma
           into item(1) item(2) item(3) item(4) item(5)

       display trim(item(1)) period trim(item(2)) period
               trim(item(3)) period trim(item(4)) period
               trim(item(5))

       goback.
       end program tokenize.
Output:
prompt$ cobc -xj tokenize.cob
Hello.How.Are.You.Today

CoffeeScript

arr = "Hello,How,Are,You,Today".split ","
console.log arr.join "."

ColdFusion

Classic tag based CFML

<cfoutput>
  <cfset wordListTag = "Hello,How,Are,You,Today">
  #Replace( wordListTag, ",", ".", "all" )#
</cfoutput>
Output:
"Hello.How.Are.You.Today"

Script Based CFML

<cfscript>
  wordList = "Hello,How,Are,You,Today";
  splitList = replace( wordList, ",", ".", "all" );
  writeOutput( splitList );
</cfscript>
Output:
"Hello.How.Are.You.Today"

Common Lisp

There are libraries out there that handle splitting (e.g., SPLIT-SEQUENCE, and the more-general CL-PPCRE), but this is a simple one-off, too. When the words are written with write-with-periods, there is no final period after the last word.

(defun comma-split (string)
  (loop for start = 0 then (1+ finish)
        for finish = (position #\, string :start start)
        collecting (subseq string start finish)
        until (null finish)))

(defun write-with-periods (strings)
  (format t "~{~A~^.~}" strings))

Cowgol

include "cowgol.coh";
include "strings.coh";

# Tokenize a string. Note: the string is modified in place.
sub tokenize(sep: uint8, str: [uint8], out: [[uint8]]): (length: intptr) is
    length := 0;
    loop
        [out] := str;
        out := @next out;
        length := length + 1;
        while [str] != 0 and [str] != sep loop
            str := @next str;
        end loop;
        if [str] == sep then
            [str] := 0;
            str := @next str;
        else
            break;
        end if;
    end loop;
end sub;

# The string
var string: [uint8] := "Hello,How,Are,You,Today";

# Make a mutable copy
var buf: uint8[64];
CopyString(string, &buf[0]);

# Tokenize the copy
var parts: [uint8][64];
var length := tokenize(',', &buf[0], &parts[0]) as @indexof parts;

# Print each string
var i: @indexof parts := 0;
while i < length loop
    print(parts[i]);
    print(".\n");
    i := i + 1;
end loop;
Output:
Hello.
How.
Are.
You.
Today.

Crystal

puts "Hello,How,Are,You,Today".split(',').join('.')
Output:
Hello.How.Are.You.Today

D

void main() {
    import std.stdio, std.string;

    "Hello,How,Are,You,Today".split(',').join('.').writeln;
}
Output:
Hello.How.Are.You.Today

Delphi

Using String.split

program Tokenize_a_string;

{$APPTYPE CONSOLE}

uses
  System.SysUtils;

var
  Words: TArray<string>;

begin
  Words := 'Hello,How,Are,You,Today'.Split([',']);
  Writeln(string.Join(#10, Words));

  Readln;
end.

Using TStringList

program TokenizeString;

{$APPTYPE CONSOLE}

uses
  Classes;

var
  tmp: TStringList;
  i: Integer;

begin

  // Instantiate TStringList class
  tmp := TStringList.Create;
  try
    { Use the TStringList's CommaText property to get/set
      all the strings in a single comma-delimited string }
    tmp.CommaText := 'Hello,How,Are,You,Today';

    { Now loop through the TStringList and display each
      token on the console }
    for i := 0 to Pred(tmp.Count) do
      Writeln(tmp[i]);

  finally
    tmp.Free;
  end;

  Readln;

end.

The result is:

Hello
How
Are
You
Today

dt

"Hello,How,Are,You,Today" "," split "." join pl

Dyalect

var str = "Hello,How,Are,You,Today"
var strings = str.Split(',')
print(values: strings, separator: ".")
Output:
Hello.How.Are.You.Today

Déjà Vu

!print join "." split "Hello,How,Are,You,Today" ","
Output:
Hello.How.Are.You.Today

E

".".rjoin("Hello,How,Are,You,Today".split(","))

EasyLang

s$ = "Hello,How,Are,You,Today"
a$[] = strsplit s$ ","
for s$ in a$[]
   write s$ & "."
.

Elena

ELENA 6.x:

import system'routines;
import extensions;
 
public program()
{
    auto string := "Hello,How,Are,You,Today";
 
    string.splitBy(",").forEach::(s)
    {
        console.print(s,".")
    }
}

Elixir

tokens = String.split("Hello,How,Are,You,Today", ",")
IO.puts Enum.join(tokens, ".")

EMal

text value = "Hello,How,Are,You,Today"
List tokens = value.split(",")
writeLine(tokens.join("."))
# single line version
writeLine("Hello,How,Are,You,Today".split(",").join("."))
Output:
Hello.How.Are.You.Today
Hello.How.Are.You.Today

Erlang

-module(tok).
-export([start/0]).

start() ->
   Lst = string:tokens("Hello,How,Are,You,Today",","),
   io:fwrite("~s~n", [string:join(Lst,".")]),
   ok.

Euphoria

function split(sequence s, integer c)
    sequence out
    integer first, delim
    out = {}
    first = 1
    while first<=length(s) do
        delim = find_from(c,s,first)
        if delim = 0 then
            delim = length(s)+1
        end if
        out = append(out,s[first..delim-1])
        first = delim + 1
    end while
    return out
end function

sequence s
s = split("Hello,How,Are,You,Today", ',')

for i = 1 to length(s) do
    puts(1, s[i] & ',')
end for

F#

System.String.Join(".", "Hello,How,Are,You,Today".Split(','))

Factor

"Hello,How,Are,You,Today" "," split "." join print

Falcon

VBA/Python programmer's approach to this solution, not sure if it's the most falconic way

/* created by Aykayayciti Earl Lamont Montgomery
April 9th, 2018 */

a = []
a = strSplit("Hello,How,Are,You,Today", ",")
index = 0
start = 0
b = ""
for index in [ start : len(a)-1 : 1 ]
	b = b + a[index] + "."
end

> b
Output:
Hello.How.Are.You.
[Finished in 0.2s]

Fantom

A string can be split on a given character, returning a list of the intervening strings.

class Main
{
  public static Void main ()
  {
    str := "Hello,How,Are,You,Today"
    words := str.split(',')
    words.each |Str word|
    {
      echo ("${word}. ")
    }
  }
}

Fennel

Translation of: Lua
(fn string.split [self sep]
  (let [pattern (string.format "([^%s]+)" sep)
        fields {}]
    (self:gsub pattern (fn [c] (tset fields (+ 1 (length fields)) c)))
    fields))

(let [str "Hello,How,Are,You,Today"]
  (print (table.concat (str:split ",") ".")))

Forth

There is no standard string split routine, but it is easily written. The results are saved temporarily to the dictionary.

: split ( str len separator len -- tokens count )
  here >r 2swap
  begin
    2dup 2,             \ save this token ( addr len )
    2over search        \ find next separator
  while
    dup negate  here 2 cells -  +!  \ adjust last token length
    2over nip /string               \ start next search past separator
  repeat
  2drop 2drop
  r>  here over -   ( tokens length )
  dup negate allot           \ reclaim dictionary
  2 cells / ;                \ turn byte length into token count

: .tokens ( tokens count -- )
  1 ?do dup 2@ type ." ." cell+ cell+ loop 2@ type ;

s" Hello,How,Are,You,Today" s" ," split .tokens  \ Hello.How.Are.You.Today

Fortran

Works with: Fortran version 90 and later
PROGRAM Example

  CHARACTER(23) :: str = "Hello,How,Are,You,Today"
  CHARACTER(5) :: word(5)
  INTEGER :: pos1 = 1, pos2, n = 0, i

  DO
    pos2 = INDEX(str(pos1:), ",")
    IF (pos2 == 0) THEN
       n = n + 1
       word(n) = str(pos1:)
       EXIT
    END IF
    n = n + 1
    word(n) = str(pos1:pos1+pos2-2)
    pos1 = pos2+pos1
 END DO

 DO i = 1, n
   WRITE(*,"(2A)", ADVANCE="NO") TRIM(word(i)), "."
 END DO
 
END PROGRAM Example

Frink

println[join[".", split[",", "Hello,How,Are,You,Today"]]]

FutureBasic

window 1, @"Tokenize a string"

void local fn DoIt
  CFStringRef string = @"Hello,How,Are,You,Today"
  CFArrayRef tokens = fn StringComponentsSeparatedByString( string, @"," )
  print fn ArrayComponentsJoinedByString( tokens, @"." )
end fn

fn DoIt

HandleEvents
Output:
Hello.How.Are.You.Today

Gambas

Click this link to run this code

Public Sub Main()
Dim sString As String[] = Split("Hello,How,Are,You,Today")

Print sString.Join(".")

End

Output:

Hello.How.Are.You.Today

GAP

SplitString("Hello,How,Are,You,Today", ",");
# [ "Hello", "How", "Are", "You", "Today" ]

JoinStringsWithSeparator(last, ".");
# "Hello.How.Are.You.Today"

Genie

[indent=4]

init
    str:string = "Hello,How,Are,You,Today"
    words:array of string[] = str.split(",")
    joined:string = string.joinv(".", words)
    print joined
Output:
prompt$ valac tokenize.gs
prompt$ ./tokenize
Hello.How.Are.You.Today

Go

package main

import (
    "fmt"
    "strings"
)

func main() {
    s := "Hello,How,Are,You,Today"
    fmt.Println(strings.Join(strings.Split(s, ","), "."))
}

Groovy

println 'Hello,How,Are,You,Today'.split(',').join('.')

Haskell

Using Data.Text

{-# OPTIONS_GHC -XOverloadedStrings #-}
import Data.Text (splitOn,intercalate)
import qualified Data.Text.IO as T (putStrLn)

main = T.putStrLn . intercalate "." $ splitOn "," "Hello,How,Are,You,Today"

Output: Hello.How.Are.You.Today

Alternate Solution

The necessary operations are unfortunately not in the standard library (yet), but simple to write:

splitBy :: (a -> Bool) -> [a] -> [[a]]
splitBy _ [] = []
splitBy f list = first : splitBy f (dropWhile f rest) where
  (first, rest) = break f list

splitRegex :: Regex -> String -> [String]

joinWith :: [a] -> [[a]] -> [a]
joinWith d xs = concat $ List.intersperse d xs
-- "concat $ intersperse" can be replaced with "intercalate" from the Data.List in GHC 6.8 and later

putStrLn $ joinWith "." $ splitBy (== ',') $ "Hello,How,Are,You,Today"

-- using regular expression to split:
import Text.Regex
putStrLn $ joinWith "." $ splitRegex (mkRegex ",") $ "Hello,How,Are,You,Today"

Tokenizing can also be realized by using unfoldr and break:

*Main> mapM_ putStrLn $ takeWhile (not.null) $ unfoldr (Just . second(drop 1). break (==',')) "Hello,How,Are,You,Today"
Hello
How
Are
You
Today
  • You need to import the modules Data.List and Control.Arrow

As special cases, splitting / joining by white space and by newlines are provided by the Prelude functions words / unwords and lines / unlines, respectively.

HicEst

CHARACTER string="Hello,How,Are,You,Today", list

nWords = INDEX(string, ',', 256) + 1
maxWordLength = LEN(string) - 2*nWords
ALLOCATE(list, nWords*maxWordLength)

DO i = 1, nWords
  EDIT(Text=string, SePaRators=',', item=i, WordEnd, CoPyto=CHAR(i, maxWordLength, list))
ENDDO

DO i = 1, nWords
  WRITE(APPend) TRIM(CHAR(i, maxWordLength, list)), '.'
ENDDO

Icon and Unicon

procedure main()
   A := []
   "Hello,How,Are,You,Today" ? {
      while put(A, 1(tab(upto(',')),=","))
      put(A,tab(0))
      }
   every writes(!A,".")
   write()
end
Output:
 ->ss
 Hello.How.Are.You.Today.
 ->

A Unicon-specific solution is:

import util

procedure main()
   A := stringToList("Hello,How,Are,You,Today", ',')
   every writes(!A,".")
   write()
end

One wonders what the expected output should be with the input string ",,,,".

Io

"Hello,How,Are,You,Today" split(",") join(".") println

J

   s=: 'Hello,How,Are,You,Today'
   ] t=: <;._1 ',',s
+-----+---+---+---+-----+
|Hello|How|Are|You|Today|
+-----+---+---+---+-----+
   ; t,&.>'.'
Hello.How.Are.You.Today.

  '.' (I.','=s)}s  NB. two steps combined
Hello.How.Are.You.Today

Alternatively using the system library/script strings

   require 'strings'
   ',' splitstring s
+-----+---+---+---+-----+
|Hello|How|Are|You|Today|
+-----+---+---+---+-----+

   '.' joinstring ',' splitstring s
Hello.How.Are.You.Today

splitstring and joinstring also work with longer "delimiters":

   '"'([ ,~ ,) '","' joinstring ',' splitstring s
"Hello","How","Are","You","Today"

But, of course, this could be solved with simple string replacement:

   rplc&',.' s
Hello.How.Are.You.Today

The task asks us to 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. but for many purposes the original string is an adequate data structure. Note also that given a string, a list of "word start" indices and "word length" integers can be logically equivalent to having an "array of words" -- and, depending on implementation details may be a superior or inferior choice to some other representation. But, in current definition of this task, the concept of "word length" plays no useful role.

Note also that J provides several built-in concepts of parsing: split on leading delimiter, split on trailing delimiter, split J language words. Also, it's sometimes more efficient to append to a string than to prepend to it. So a common practice for parsing on an embedded delimiter is to append a copy of the delimiter to the string and then use the appended result:

   fn;._2 string,','

Here fn is applied to each ',' delimited substring and the results are assembled into an array.

Or, factoring out the names:

   fn ((;._2)(@(,&','))) string

Java

Works with: Java version 1.0+

There are multiple ways to tokenize a String in Java.

The first is by splitting the String into an array of Strings. The separator is actually a regular expression so you could do very powerful things with this, but make sure to escape any characters with special meaning in regex.

Works with: Java version 1.8+
String toTokenize = "Hello,How,Are,You,Today";
System.out.println(String.join(".", toTokenize.split(",")));
Works with: Java version 1.4+
String toTokenize = "Hello,How,Are,You,Today";

String words[] = toTokenize.split(",");//splits on one comma, multiple commas yield multiple splits
               //toTokenize.split(",+") if you want to ignore empty fields
for(int i=0; i<words.length; i++) {
    System.out.print(words[i] + ".");
}

The other way is to use StringTokenizer. It will skip any empty tokens. So if two commas are given in line, there will be an empty string in the array given by the split function, but no empty string with the StringTokenizer object. This method takes more code to use, but allows you to get tokens incrementally instead of all at once.

Works with: Java version 1.0+
String toTokenize = "Hello,How,Are,You,Today";

StringTokenizer tokenizer = new StringTokenizer(toTokenize, ",");
while(tokenizer.hasMoreTokens()) {
    System.out.print(tokenizer.nextToken() + ".");
}

JavaScript

console.log(
    "Hello,How,Are,You,Today"
        .split(",")
        .join(".")
);

A more advanced program to tokenise strings:

const Tokeniser = (function () {
	const numberRegex = /-?(\d+\.d+|\d+\.|\.\d+|\d+)((e|E)(\+|-)?\d+)?/g;
	return {
		settings: {
			operators: ["<", ">", "=", "+", "-", "*", "/", "?", "!"],
			separators: [",", ".", ";", ":", " ", "\t", "\n"],
			groupers: ["(", ")", "[", "]", "{", "}", '"', '"', "'", "'"],
			keepWhiteSpacesAsTokens: false,
			trimTokens: true
		},
		isNumber: function (value) {
			if (typeof value === "number") {
				return true;
			} else if (typeof value === "string") {
				return numberRegex.test(value);
			}
			return false;
		},
		closeGrouper: function (grouper) {
			if (this.settings.groupers.includes(grouper)) {
				return this.settings.groupers[this.settings.groupers.indexOf(grouper) + 1];
			}
			return null;
		},
		tokenType: function (char) {
			if (this.settings.operators.includes(char)) {
				return "operator";
			} else if (this.settings.separators.includes(char)) {
				return "separator";
			} else if (this.settings.groupers.includes(char)) {
				return "grouper";
			}
			return "other";
		},
		parseString: function (str) {
			if (typeof str !== "string") {
				if (str === null) {
					return "null";
				} if (typeof str === "object") {
					str = JSON.stringify(str);
				} else {
					str = str.toString();
				}
			}
			let tokens = [], _tempToken = "";
			for (let i = 0; i < str.length; i++) {
				if (this.tokenType(_tempToken) !== this.tokenType(str[i]) || this.tokenType(str[i]) === "separator") {
					if (_tempToken.trim() !== "") {
						tokens.push(this.settings.trimTokens ? _tempToken.trim() : _tempToken);
					} else if (this.settings.keepWhiteSpacesAsTokens) {
						tokens.push(_tempToken);
					}
					_tempToken = str[i];
					if (this.tokenType(_tempToken) === "separator") {
						if (_tempToken.trim() !== "") {
							tokens.push(this.settings.trimTokens ? _tempToken.trim() : _tempToken);
						} else if (this.settings.keepWhiteSpacesAsTokens) {
							tokens.push(_tempToken);
						}
						_tempToken = "";
					}
				} else {
					_tempToken += str[i];
				}
			}
			if (_tempToken.trim() !== "") {
				tokens.push(this.settings.trimTokens ? _tempToken.trim() : _tempToken);
			} else if (this.settings.keepWhiteSpacesAsTokens) {
				tokens.push(_tempToken);
			}
			return tokens.filter((token) => token !== "");
		}
	};
})();

Output:

Tokeniser.parseString("Hello,How,Are,You,Today");

// -> ['Hello', ',', 'How', ',', 'Are', ',', 'You', ',', 'Today']

jq

split(",") | join(".")

Example:

$ jq -r 'split(",") | join(".")'
"Hello,How,Are,You,Today" 
Hello.How.Are.You.Today

Jsish

Being in the ECMAScript family, Jsi is blessed with many easy to use character, string and array manipulation routines.

puts('Hello,How,Are,You,Today'.split(',').join('.'))
Output:
Hello.How.Are.You.Today

Julia

s = "Hello,How,Are,You,Today"
a = split(s, ",")
t = join(a, ".")

println("The string \"", s, "\"")
println("Splits into ", a)
println("Reconstitutes to \"", t, "\"")
Output:
The string "Hello,How,Are,You,Today"
Splits into SubString{ASCIIString}["Hello","How","Are","You","Today"]
Reconstitutes to "Hello.How.Are.You.Today"

K

words: "," \: "Hello,How,Are,You,Today"
"." /: words
Output:
"Hello.How.Are.You.Today"
Works with: ngn/k
","\"Hello,How,Are,You,Today"
("Hello"
 "How"
 "Are"
 "You"
 "Today")

Klingphix

( "Hello,How,Are,You,Today" "," ) split len [ get print "." print ] for

nl "End " input
Output:
Hello.How.Are.You.Today.
End

Kotlin

Works with: Kotlin version 1.0b4
fun main(args: Array<String>) {
    val input = "Hello,How,Are,You,Today"
    println(input.split(',').joinToString("."))
}
Output:
Hello.How.Are.You.Today

Ksh

#!/bin/ksh

# Tokenize a string

#	# Variables:
#
string="Hello,How,Are,You,Today"
inputdelim=\,		# a comma
outputdelim=\.		# a period

#	# Functions:
#
#	# Function _tokenize(str, indelim, outdelim)
#
function _tokenize {
	typeset _str ; _str="$1"
	typeset _ind ; _ind="$2"
	typeset _outd ; _outd="$3"
	
	while [[ ${_str} != ${_str/${_ind}/${_outd}} ]]; do
		_str=${_str/${_ind}/${_outd}}
	done

	echo "${_str}"
}

 ######
# main #
 ######

 _tokenize "${string}" "${inputdelim}" "${outputdelim}"
Output:
Hello.How.Are.You.Today

LabVIEW

To tokenize the string, we use the Search/Split String function to split the string by its first comma. Add the beginning (up to, but not including the comma) to the end of the array, remove the first comma from the rest of the string, and pass it back through the shift register to the loop's next iteration. This is repeated until the string is empty. Printing is a simple matter of concatenation.
This image is a VI Snippet, an executable image of LabVIEW code. The LabVIEW version is shown on the top-right hand corner. You can download it, then drag-and-drop it onto the LabVIEW block diagram from a file browser, and it will appear as runnable, editable code.

Lambdatalk

{S.replace , by . in Hello,How,Are,You,Today}.
-> Hello.How.Are.You.Today.

Lang

$str = Hello,How,Are,You,Today
fn.println(fn.join(\., fn.split($str, \,)))

Lang5

'Hello,How,Are,You,Today ', split '. join .

LDPL

DATA:
explode/words is text vector
explode/index is number
explode/string is text
explode/length is number
explode/stringlength is number
explode/current-token is text
explode/char is text
explode/separator is text
i is number
    
PROCEDURE:
# Ask for a sentence
display "Enter a sentence: "
accept explode/string

# Declare explode Subprocedure
# Splits a text into a text vector by a certain delimiter
# Input parameters:
# - explode/string: the string to explode (destroyed)
# - explode/separator: the character used to separate the string (preserved)
# Output parameters:
# - explode/words: vector of splitted words
# - explode/length: length of explode/words
sub-procedure explode
    join explode/string and explode/separator in explode/string
    store length of explode/string in explode/stringlength
    store 0 in explode/index
    store 0 in explode/length
    store "" in explode/current-token
    while explode/index is less than explode/stringlength do
        get character at explode/index from explode/string in explode/char
        if explode/char is equal to explode/separator then
            store explode/current-token in explode/words:explode/length
            add explode/length and 1 in explode/length
            store "" in explode/current-token
        else
            join explode/current-token and explode/char in explode/current-token
        end if
        add explode/index and 1 in explode/index
    repeat
    subtract 1 from explode/length in explode/length
end sub-procedure

# Separate the entered string
store " " in explode/separator
call sub-procedure explode
while i is less than or equal to explode/length do
    display explode/words:i crlf
    add 1 and i in i
repeat

LFE

> (set split (string:tokens "Hello,How,Are,You,Today" ","))
("Hello" "How" "Are" "You" "Today")
> (string:join split ".")
"Hello.How.Are.You.Today"

Lingo

input = "Hello,How,Are,You,Today"
_player.itemDelimiter = ","
output = ""
repeat with i = 1 to input.item.count
  put input.item[i]&"." after output
end repeat
delete the last char of output
put output
-- "Hello.How.Are.You.Today"

Works with: UCB Logo
to split :str :sep
  output parse map [ifelse ? = :sep ["| |] [?]] :str
end

This form is more robust, doing the right thing if there are embedded spaces.

to split :str :by [:acc []] [:w "||]
  if empty? :str [output lput :w :acc]
  ifelse equal? first :str :by ~
    [output (split butfirst :str :by lput :w :acc)] ~
    [output (split butfirst :str :by         :acc  lput first :str :w)]
end
? show split "Hello,How,Are,You,Today ",
[Hello How Are You Today]

Logtalk

Using Logtalk built-in support for Definite Clause Grammars (DCGs) and representing the strings as atoms for readbility:

:- object(spliting).

    :- public(convert/2).
    :- mode(convert(+atom, -atom), one).

    convert(StringIn, StringOut) :-
        atom_chars(StringIn, CharactersIn),
        phrase(split(',', Tokens), CharactersIn),
        phrase(split('.', Tokens), CharactersOut),
        atom_chars(StringOut, CharactersOut).

    split(Separator, [t([Character| Characters])| Tokens]) -->
        [Character], {Character \== Separator}, split(Separator, [t(Characters)| Tokens]).
    split(Separator, [t([])| Tokens]) -->
        [Separator], split(Separator, Tokens).
    split(_, [t([])]) -->
        [].
    % the look-ahead in the next rule prevents adding a spurious separator at the end
    split(_, []), [Character] -->
        [Character].

:- end_object.
Output:
| ?- spliting::convert('Hello,How,Are,You,Today', Converted).
Converted = 'Hello.How.Are.You.Today'
yes

Lua

Split function callously stolen from the lua-users wiki

function string:split (sep)
    local sep, fields = sep or ":", {}
    local pattern = string.format("([^%s]+)", sep)
    self:gsub(pattern, function(c) fields[#fields+1] = c end)
    return fields
end

local str = "Hello,How,Are,You,Today"
print(table.concat(str:split(","), "."))
Output:
Hello.How.Are.You.Today

M2000 Interpreter

Module CheckIt {
	Function Tokenize$(s){
		\\ letter$ pop a string from stack of values
		\\ shift 2 swap top two values on stack of values
		fold1=lambda m=1 ->{
			shift 2 :if m=1 then m=0:drop: push letter$ else push letter$+"."+letter$
		}
		=s#fold$(fold1)
	}
	Print Tokenize$(piece$("Hello,How,Are,You,Today",",")) ="Hello.How.Are.You.Today"   ' true
}
Checkit

M4

define(`s',`Hello,How,Are,You,Today')
define(`set',`define(`$1[$2]',`$3')')
define(`get',`defn($1[$2])')
define(`n',0)
define(`fill',
   `set(a,n,$1)`'define(`n',incr(n))`'ifelse(eval($#>1),1,`fill(shift($@))')')
fill(s)
define(`j',0)
define(`show',
   `ifelse(eval(j<n),1,`get(a,j).`'define(`j',incr(j))`'show')')
show
Output:
 Hello.How.Are.You.Today.

Maple

StringTools:-Join(StringTools:-Split("Hello,How,Are,You,Today", ","),".");
Output:
"Hello.How.Are.You.Today"

Mathematica/Wolfram Language

StringJoin@StringSplit["Hello,How,Are,You,Today", "," -> "."]

MATLAB / Octave

s=strsplit('Hello,How,Are,You,Today',',')     
fprintf(1,'%s.',s{:})
Output:
Hello.How.Are.You.Today.

Maxima

l: split("Hello,How,Are,You,Today", ",")$
printf(true, "~{~a~^.~}~%", l)$

A slightly different way

split("Hello,How,Are,You,Today",",")$
simplode(%,".");
Output:
"Hello.How.Are.You.Today"

MAXScript

output = ""
for word in (filterString "Hello,How,Are,You,Today" ",") do
(
    output += (word + ".")
)
format "%\n" output

Mercury

:- module string_tokenize.
:- interface.

:- import_module io.
:- pred main(io::di, io::uo) is det.

:- implementation.
:- import_module list, string.

main(!IO) :-
    Tokens = string.split_at_char((','), "Hello,How,Are,You,Today"),   
    io.write_list(Tokens, ".", io.write_string, !IO),
    io.nl(!IO).

min

Works with: min version 0.19.3
"Hello,How,Are,You,Today" "," split "." join print

MiniScript

tokens = "Hello,How,Are,You,Today".split(",")
print tokens.join(".")

MMIX

sep	IS	','
EOS	IS	0
NL	IS	10

// main registers
p	IS	$255
tp	GREG
c	GREG
t	GREG

	LOC	Data_Segment
	GREG	@
Text	BYTE	"Hello,How,Are,You,Today",EOS
token	BYTE	0
eot	IS	@+255

	LOC	#100	% main () {
Main	LDA	p,Text		%
	LDA	tp,token	% initialize pointers
2H	LDBU	c,p		% DO  get char
	BZ	c,5F		%  break if char == EOS
	CMP	t,c,sep		%  if char != sep then
	PBNZ	t,3F		%     store char
	SET	t,NL		%  terminate token with NL,EOS
	STBU	t,tp
	SET	t,EOS
	INCL	tp,1
	STBU	t,tp
	JMP	4F		%  continue

3H	STBU	c,tp		%  store char
4H	INCL	tp,1		%  update pointers
	INCL	p,1
	JMP	2B		% LOOP

5H	SET	t,NL		% terminate last token and buffer
	STBU	t,tp
	SET	t,EOS
	INCL	tp,1
	STBU	t,tp
%  next part is not really necessary
%  program runs only once
%	INCL	tp,1		% terminate buffer
%	STBU	t,tp

	LDA	tp,token	% reset token pointer
				% REPEAT
2H	ADD	p,tp,0		%    start of token
	TRAP	0,Fputs,StdOut	%    output token
	ADD	tp,tp,p
	INCL	tp,1		%    step to next token
	LDBU	t,tp
	PBNZ	t,2B		% UNTIL EOB(uffer)
	TRAP	0,Halt,0
Output:
 ~/MIX/MMIX/Progs> mmix tokenizing
 Hello
 How
 Are
 You
 Today

Modula-3

MODULE Tokenize EXPORTS Main;

IMPORT IO, TextConv;

TYPE Texts = REF ARRAY OF TEXT;

VAR tokens: Texts;
    string := "Hello,How,Are,You,Today";
    sep := SET OF CHAR {','};

BEGIN
  tokens := NEW(Texts, TextConv.ExplodedSize(string, sep));
  TextConv.Explode(string, tokens^, sep);
  FOR i := FIRST(tokens^) TO LAST(tokens^) DO
    IO.Put(tokens[i] & ".");
  END;
  IO.Put("\n");
END Tokenize.

MUMPS

TOKENS
 NEW I,J,INP
 SET INP="Hello,how,are,you,today"
 NEW I FOR I=1:1:$LENGTH(INP,",") SET INP(I)=$PIECE(INP,",",I)
 NEW J FOR J=1:1:I WRITE INP(J) WRITE:J'=I "."
 KILL I,J,INP  // Kill is optional. "New" variables automatically are killed on "Quit"
 QUIT

In use:

USER>D TOKENS^ROSETTA
Hello.how.are.you.today

Nanoquery

for word in "Hello,How,Are,You,Today".split(",")
        print word + "."
end
Output:
Hello.How.Are.You.Today.

Nemerle

using System;
using System.Console;
using Nemerle.Utility.NString;

module Tokenize
{
    Main() : void
    {
        def cswords = "Hello,How,Are,You,Today";
        WriteLine(Concat(".", $[s | s in cswords.Split(',')]));
        // Split() produces an array while Concat() consumes a list
        // a quick in place list comprehension takes care of that
    }
}

NetRexx

/*NetRexx program *****************************************************
* 20.08.2012 Walter Pachl derived from REXX Version 3
**********************************************************************/
  sss='Hello,How,Are,You,Today'
  Say 'input string='sss
  Say ''
  Say 'Words in the string:'
  ss =sss.translate(' ',',')
  Loop i=1 To ss.words()
    Say ss.word(i)'.'
    End
  Say 'End-of-list.'

Output as in REXX version

NewLISP

(print (join (parse "Hello,How,Are,You,Today" ",") "."))

Nial

Example for Q'Nial7, using set "nodecor and set "diagram switches for better display of the array structure:

Define Array with input string:

     s := 'Hello,How,Are,You,Today'
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|H|e|l|l|o|,|H|o|w|,|A|r|e|,|Y|o|u|,|T|o|d|a|y|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Split string at the commas:

     t := s eachall = `, cut s
+-----------+-------+-------+-------+-----------+
|+-+-+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+-+-+|
||H|e|l|l|o|||H|o|w|||A|r|e|||Y|o|u|||T|o|d|a|y||
|+-+-+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+-+-+|
+-----------+-------+-------+-------+-----------+

Join string with . and remove last .

     u := front content (cart t `.)
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|H|e|l|l|o|.|H|o|w|.|A|r|e|.|Y|o|u|.|T|o|d|a|y|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Less cluttered display, using set "sketch;set "nodecor display switches.

     s:='Hello,How,Are,You,Today'
Hello,How,Are,You,Today
     t:= s eachall = `, cut s
+-----+---+---+---+-----+
|Hello|How|Are|You|Today|
+-----+---+---+---+-----+
     u:=front content (cart t `.)

Hello.How.Are.You.Today

Or as a one-liner:

front content (cart (s eachall = `, cut s) `.)

Nim

import strutils

let text = "Hello,How,Are,You,Today"
let tokens = text.split(',')
echo tokens.join(".")
Output:
Hello.How.Are.You.Today

Objeck

class Parse {
  function : Main(args : String[]) ~ Nil {
    tokens := "Hello,How,Are,You,Today"->Split(",");
    each(i : tokens) {
      tokens[i]->PrintLine();
    };
  }
}

Objective-C

Works with: GNUstep
Works with: Cocoa
NSString *text = @"Hello,How,Are,You,Today";
NSArray *tokens = [text componentsSeparatedByString:@","];
NSString *result = [tokens componentsJoinedByString:@"."];
NSLog(result);

OCaml

To split on a single-character separator:

let words = String.split_on_char ',' "Hello,How,Are,You,Today" in
String.concat "." words

The function split_on_char has been introduced in OCaml 4.04. In previous versions, it could be implemented by:

let split_on_char sep s =
  let r = ref [] in
  let j = ref (String.length s) in
  for i = String.length s - 1 downto 0 do
    if s.[i] = sep then begin
      r := String.sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  String.sub s 0 !j :: !r

Oforth

"Hello,How,Are,You,Today" wordsWith(',') println
Output:
[Hello, How, Are, You, Today]

ooRexx

text='Hello,How,Are,You,Today'
do while text \= ''
   parse var text word1 ',' text
   call charout 'STDOUT:',word1'.'
end
Output:
Hello.How.Are.You.Today.

OpenEdge/Progress

FUNCTION tokenizeString RETURNS CHAR (
   i_c AS CHAR
):

   DEF VAR ii        AS INT.
   DEF VAR carray    AS CHAR EXTENT.
   DEF VAR cresult   AS CHAR.

   EXTENT( carray ) = NUM-ENTRIES( i_c ).

   DO ii = 1 TO NUM-ENTRIES( i_c ):
      carray[ ii ] = ENTRY( ii, i_c ).
   END.

   DO ii = 1 TO EXTENT( carray ).
      cresult = cresult + "." + carray[ ii ].
   END.
   RETURN SUBSTRING( cresult, 2 ).

END FUNCTION. /* tokenizeString */

MESSAGE 
   tokenizeString( "Hello,How,Are,You,Today" ) 
VIEW-AS ALERT-BOX.
Output:
 ---------------------------
 Message
 ---------------------------
 Hello.How.Are.You.Today
 ---------------------------
 OK   
 ---------------------------

Oz

for T in {String.tokens "Hello,How,Are,You,Today" &,} do
   {System.printInfo T#"."}
end

PARI/GP

Version #1.

Simple version, like the most custom ones here (for this task). This version has 1 character delimiter, which is not allowed in the beginning and at the end of string, in addition, double, triple, etc., delimiters are not allowed too.

Works with: PARI/GP version 2.7.4 and above
\\ Tokenize a string str according to 1 character delimiter d. Return a list of tokens.
\\ Using ssubstr() from http://rosettacode.org/wiki/Substring#PARI.2FGP
\\ tokenize() 3/5/16 aev
tokenize(str,d)={
my(str=Str(str,d),vt=Vecsmall(str),d1=sasc(d),Lr=List(),sn=#str,v1,p1=1);
for(i=p1,sn, v1=vt[i]; if(v1==d1, listput(Lr,ssubstr(str,p1,i-p1)); p1=i+1)); 
return(Lr);
}

{
\\ TEST 
print(" *** Testing tokenize from Version #1:");
print("1.", tokenize("Hello,How,Are,You,Today",","));
\\ BOTH 2 & 3 are NOT OK!!
print("2.",tokenize("Hello,How,Are,You,Today,",","));
print("3.",tokenize(",Hello,,How,Are,You,Today",","));
}
Output:
 *** Testing tokenize from Version #1:
1.List(["Hello", "How", "Are", "You", "Today"])
2.List(["Hello", "How", "Are", "You", "Today", ","])
3.List([",Hello,,How,Are,You,Today,", "Hello", ",How,Are,You,Today,", "How", "Ar
e", "You", "Today"])

Version #2.

Advanced version. Delimiter is allowed in any place. In addition, multiple delimiters are allowed too. This is really useful for considering omitted data. This version can be used for positional parameters processing, or for processing data from tables with string rows.

Works with: PARI/GP version 2.7.4 and above
\\ Tokenize a string str according to 1 character delimiter d. Return a list of tokens.
\\ Using ssubstr() from http://rosettacode.org/wiki/Substring#PARI.2FGP
\\ stok() 3/5/16 aev
stok(str,d)={
my(d1c=ssubstr(d,1,1),str=Str(str,d1c),vt=Vecsmall(str),d1=sasc(d1c),
   Lr=List(),sn=#str,v1,p1=1,vo=32);
if(sn==1, return(List(""))); if(vt[sn-1]==d1,sn--);
for(i=1,sn, v1=vt[i];
    if(v1!=d1, vo=v1; next);
    if(vo==d1||i==1, listput(Lr,""); p1=i+1; vo=v1; next);
    if(i-p1>0, listput(Lr,ssubstr(str,p1,i-p1)); p1=i+1);
    vo=v1;
   ); 
return(Lr);
}

{
\\ TEST 
print(" *** Testing stok from Version #2:");
\\ pp - positional parameter(s)
print("1. 5 pp: ", stok("Hello,How,Are,You,Today",","));
print("2. 5 pp: ", stok("Hello,How,Are,You,Today,",","));
print("3. 9 pp: ", stok(",,Hello,,,How,Are,You,Today",","));
print("4. 6 pp: ", stok(",,,,,,",","));
print("5. 1 pp: ", stok(",",","));
print("6. 1 pp: ", stok("Hello-o-o??",","));
print("7. 0 pp: ", stok("",","));
}
Output:
 *** Testing stok from Version #2:
1. 5 pp: List(["Hello", "How", "Are", "You", "Today"])
2. 5 pp: List(["Hello", "How", "Are", "You", "Today"])
3. 9 pp: List(["", "", "Hello", "", "", "How", "Are", "You", "Today"])
4. 6 pp: List(["", "", "", "", "", ""])
5. 1 pp: List([""])
6. 1 pp: List(["Hello-o-o??"])
7. 0 pp: List([""])

Pascal

Works with: Free_Pascal
program TokenizeString;

{$mode objfpc}{$H+}

uses
  SysUtils, Classes;
const
  TestString = 'Hello,How,Are,You,Today';
var
  Tokens: TStringList;
  I: Integer;
begin
  // Uses FCL facilities, "harder" algorithm not implemented
  Tokens := TStringList.Create;
  try
    Tokens.Delimiter := ',';
    Tokens.DelimitedText := TestString;
    Tokens.Delimiter := '.'; // For example
    // To standard Output
    WriteLn(Format('Tokenize from: "%s"', [TestString]));
    WriteLn(Format('to:            "%s"',[Tokens.DelimitedText]));
  finally
    Tokens.Free;
  end;
end.

The result is:

Tokenize from: "Hello,How,Are,You,Today"
to:            "Hello.How.Are.You.Today"

Perl

print join('.', split /,/, 'Hello,How,Are,You,Today'), "\n";

CLI one-liner form:

echo "Hello,How,Are,You,Today" | perl -aplF/,/ -e '$" = "."; $_ = "@F";'

which is a compact way of telling Perl to do

BEGIN { $/ = "\n"; $\ = "\n"; }
LINE: while (defined($_ = <ARGV>)) {
    chomp $_;
    our(@F) = split(/,/, $_, 0);
    $" = '.';
    $_ = "@F";
}
continue {
    die "-p destination: $!\n" unless print $_;
}

Phix

?join(split("Hello,How,Are,You,Today",","),".")
Output:
"Hello.How.Are.You.Today"

Phixmonti

/# "Hello,How,Are,You,Today" "," "." subst print #/
"Hello,How,Are,You,Today" "," " " subst split len for get print "." print endfor

PHP

Works with: PHP version 5.x
<?php
$str = 'Hello,How,Are,You,Today';
echo implode('.', explode(',', $str));
?>

Picat

Using the built-in functions split/2 and join/2.

import util.

go =>
  S = "Hello,How,Are,You,Today",
  T = S.split(","),
  println(T),
  T.join(".").println(),

  % As a one liner:
  S.split(",").join(".").println().
Output:
[Hello,How,Are,You,Today]
Hello.How.Are.You.Today
Hello.How.Are.You.Today

PicoLisp

(mapcar pack
   (split (chop "Hello,How,Are,You,Today") ",") )

Pike

("Hello,How,Are,You,Today" / ",") * ".";

PL/I

tok: Proc Options(main);
declare s character (100) initial ('Hello,How,Are,You,Today');
declare n fixed binary (31);

n = tally(s, ',')+1;

begin;
   declare table(n) character (50) varying;
   declare c character (1);
   declare (i, k) fixed binary (31);

   table = ''; k = 1;
   do i = 1 to length(s);
      c = substr(s, i, 1);
      if c = ',' then k = k + 1;
      else table(k) = table(k) || c;
   end;

   /* display the table */
   table = table || '.';
   put skip list (string(table));
end;
end;
Output:
Hello.How.Are.You.Today

PL/M

100H:
/* CP/M CALLS */
BDOS: PROCEDURE (FN, ARG); DECLARE FN BYTE, ARG ADDRESS; GO TO 5; END BDOS;
EXIT: PROCEDURE; CALL BDOS(0,0); END EXIT;
PRINT: PROCEDURE (S); DECLARE S ADDRESS; CALL BDOS(9,S); END PRINT;

/* SPLIT A STRING ON CHARACTER 'SEP'. 
   THE 'PARTS' ARRAY WILL CONTAIN POINTERS TO THE START OF EACH ELEMENT.
   THE AMOUNT OF PARTS IS RETURNED. 
*/   
TOKENIZE: PROCEDURE (SEP, STR, PARTS) ADDRESS;
    DECLARE SEP BYTE, (STR, PARTS) ADDRESS;
    DECLARE (N, P BASED PARTS) ADDRESS;
    DECLARE CH BASED STR BYTE;
    N = 0;
LOOP:
    P(N) = STR;
    N = N + 1;
    DO WHILE CH <> '$' AND CH <> SEP;
        STR = STR + 1;
    END;
    IF CH = '$' THEN RETURN N;       
    CH = '$';
    STR = STR + 1;
    GO TO LOOP;
END TOKENIZE;

/* TEST ON THE GIVEN INPUT */
DECLARE HELLO (24) BYTE INITIAL ('HELLO,HOW,ARE,YOU,TODAY$');
DECLARE PARTS (10) ADDRESS;
DECLARE (I, LEN) ADDRESS;

LEN = TOKENIZE(',', .HELLO, .PARTS);
DO I = 0 TO LEN-1;
    CALL PRINT(PARTS(I));
    CALL PRINT(.'. $');
END;

CALL EXIT;
EOF;
Output:
HELLO. HOW. ARE. YOU. TODAY. 

Plain English

To run:
Start up.
Split "Hello,How,Are,You,Today" into some string things given the comma byte.
Join the string things with the period byte giving a string.
Destroy the string things.
Write the string on the console.
Wait for the escape key.
Shut down.

To join some string things with a byte giving a string:
Get a string thing from the string things.
Loop.
If the string thing is nil, exit.
Append the string thing's string to the string.
If the string thing's next is not nil, append the byte to the string.
Put the string thing's next into the string thing.
Repeat.
Output:
Hello.How.Are.You.Today

Pop11

The natural solution in Pop11 uses lists.

There are built in libraries for tokenising strings, illustrated below, along with code that the user could create for the task.

First show the use of sysparse_string to break up a string and make a list of strings.

;;; Make a list of strings from a string using space as separator
lvars list;
sysparse_string('the cat sat on the mat') -> list;
;;; print the list of strings
list =>
** [the cat sat on the mat]

By giving it an extra parameter 'true' we can make it recognize numbers and produce a list of strings and numbers

lvars list;
sysparse_string('one 1 two 2 three 3 four 4', true) -> list;
;;; print the list of strings and numbers
list =>
** [one 1 two 2 three 3 four 4]
;;; check that first item is a string and second an integer
isstring(list(1))=>
** <true>
isinteger(list(2))=>
** <true>

Now show some uses of the built in procedure sys_parse_string, which allows more options:

;;; Make pop-11 print strings with quotes
true -> pop_pr_quotes;
;;;
;;; Create a string of tokens using comma as token separator
lvars str='Hello,How,Are,You,Today';
;;;
;;; Make a list of strings by applying sys_parse_string
;;; to str, using the character `,` as separator (the default
;;; separator, if none is provided, is the space character).
lvars strings;
[% sys_parse_string(str, `,`) %] -> strings;
;;;
;;; print the list of strings
strings =>
** ['Hello' 'How' 'Are' 'You' 'Today']

If {% ... %} were used instead of [% ... %] the result would be a vector (i.e. array) of strings rather than a list of strings.

{% sys_parse_string(str, `,`) %} -> strings;
;;; print the vector
strings =>
** {'Hello' 'How' 'Are' 'You' 'Today'}

It is also possible to give sys_parse_string a 'conversion' procedure, which is applied to each of the tokens. E.g. it could be used to produce a vector of numbers, using the conversion procedure 'strnumber', which converts a string to a number:

lvars numbers;
{% sys_parse_string('100 101 102 103 99.9 99.999', strnumber) %} -> numbers;
;;; the result is a vector containing integers and floats,
;;; which can be printed thus:
numbers =>
** {100 101 102 103 99.9 99.999}

Using lower level pop-11 facilities to tokenise the string:

;;; Declare and initialize variables
lvars str='Hello,How,Are,You,Today';
;;; Iterate over string
lvars ls = [], i, j = 1;
for i from 1 to length(str) do
    ;;; If comma
    if str(i) = `,` then
       ;;; Prepend word (substring) to list
       cons(substring(j, i - j, str), ls) -> ls;
       i + 1 -> j;
    endif;
endfor;
;;; Prepend final word (if needed)
if j <= length(str) then
    cons(substring(j, length(str) - j + 1, str), ls) -> ls;
endif;
;;; Reverse the list
rev(ls) -> ls;

Since the task requires to use array we convert list to array

;;; Put list elements and lenght on the stack
destlist(ls);
;;; Build a vector from them
lvars ar = consvector();
;;; Display in a loop, putting trailing period
for i from 1 to length(ar) do
   printf(ar(i), '%s.');
endfor;
printf('\n');

We could use list directly for printing:

for i in ls do
    printf(i, '%s.');
endfor;

so the conversion to vector is purely to satisfy task formulation.

PowerShell

Works with: PowerShell version 1
$words = "Hello,How,Are,You,Today".Split(',')
[string]::Join('.', $words)
Works with: PowerShell version 2
$words = "Hello,How,Are,You,Today" -split ','
$words -join '.'
Works with: PowerShell version 2

The StringSplitOptions enumeration weeds out the return of empty elements.

"Hello,How,Are,You,Today", ",,Hello,,Goodbye,," | ForEach-Object {($_.Split(',',[StringSplitOptions]::RemoveEmptyEntries)) -join "."}
Output:
Hello.How.Are.You.Today
Hello.Goodbye

Prolog

Works with: SWI Prolog
splitup(Sep,[token(B)|BL]) --> splitup(Sep,B,BL).
splitup(Sep,[A|AL],B)      --> [A], {\+ [A] = Sep }, splitup(Sep,AL,B).
splitup(Sep,[],[B|BL])     --> Sep, splitup(Sep,B,BL).
splitup(_Sep,[],[])        --> [].
start :-
    phrase(splitup(",",Tokens),"Hello,How,Are,You,Today"),
    phrase(splitup(".",Tokens),Backtogether),
    string_to_list(ABack,Backtogether),
    writeln(ABack).
Output:
 ?- start.
 Hello.How.Are.You.Today
Works with: SWI Prolog 7

Using the SWI Prolog string data type and accompanying predicates, this can be accomplished in a few lines in the top level:

?- split_string("Hello,How,Are,You,Today", ",", "", Split),
|    atomics_to_string(Split, ".", PeriodSeparated),
|    writeln(PeriodSeparated).
Hello.How.Are.You.Today

Python

Works with: Python version 2.5
Works with: Python version 3.0
text = "Hello,How,Are,You,Today"
tokens = text.split(',')
print ('.'.join(tokens))

Or if interpretation of the task description means you don't need to keep an intermediate array:

print ('.'.join('Hello,How,Are,You,Today'.split(',')))

Q

words: "," vs "Hello,How,Are,You,Today"
"." sv words
Output:
"Hello.How.Are.You.Today"

QB64

CBTJD: 2020/03/12

a$ = "Hello,How,Are,You,Today" '               | Initialize original string.
FOR na = 1 TO LEN(a$) '                        | Start loop to count number of commas.
  IF MID$(a$, na, 1) = "," THEN nc = nc + 1 '  | For each comma, increment nc.
NEXT '                                         | End of loop.
DIM t$(nc) '                                   | Dim t$ array with total number of commas (nc). Array base is 0.
FOR nb = 1 TO LEN(a$) '                        | Start loop to find each word.
  c$ = MID$(a$, nb, 1) '                       | Look at each character in the string.
  IF c$ = "," THEN '                           | If the character is a comma, increase the t$ array for the next word.
    t = t + 1 '                                | t = token word count. Starts at 0 because array base is 0.
  ELSE '                                       | Or...
    t$(t) = t$(t) + c$ '                       | Add each character to the current token (t$) word.
  END IF '                                     | End of decision tree.
NEXT '                                         | End of loop.
FOR nd = 0 TO t '                              | Start loop to create final desired output.
  tf$ = tf$ + t$(nd) + "." '                   | Add each token word from t$ followed by a period to the final tf$.
NEXT '                                         | End of loop.
PRINT LEFT$(tf$, LEN(tf$) - 1) '               | Print all but the last period of tf$.
END '                                          | Program end.

Alternative method using word$ function:


CBTJD: 2020/03/12

a$ = "Hello,How,Are,You,Today" '                        | Initialize original string.
DIM t$(LEN(a$) / 2) '                                   | Create an overestimated sized array.
FOR nd = 1 TO LEN(a$) '                                 | Start loop to find each comma.
  IF MID$(a$, nd, 1) = "," THEN '                       | If a comma is found...
    tc = tc + 1 '                                       | Increment tc for each found comma.
    t$(tc) = word$(a$, tc, ",") '                       | Assign tc word to t$(tc) array.
  END IF '                                              | End decision tree.
NEXT '                                                  | End loop.
t$(tc + 1) = word$(a$, tc + 1, ",") '                   | Assign last word to next array position.
ft$ = t$(1) '                                           | Start final return string ft$ with first array value.
FOR ne = 2 TO tc + 1 '                                  | Start loop to add periods and array values.
  ft$ = ft$ + "." + t$(ne) '                            | Concatenate a period with subsequent array values.
NEXT '                                                  | End loop.
PRINT ft$ '                                             | Print final return string ft$.

FUNCTION word$ (inSTG$, inDEC, inPRM$) '                | word$ function accepts original string, word number, and separator.
  inSTG$ = inSTG$ + inPRM$ '                            | Add a separator to the end of the original string.
  FOR na = 1 TO LEN(inSTG$) '                           | Start loop to count total number of separators.
    IF MID$(inSTG$, na, 1) = inPRM$ THEN nc = nc + 1 '  | If separator found, increment nc.
  NEXT '                                                | End loop.
  IF inDEC > nc THEN word$ = "": GOTO DONE '            | If requested word number (inDEC) is greater than total words (nc), bail.
  FOR nd = 1 TO inDEC '                                 | Start loop to find requested numbered word.
    last = st '                                         | Remember the position of the last separator.
    st = INSTR(last + 1, inSTG$, inPRM$) '              | Find the next separator.
  NEXT '                                                | End loop.
  word$ = MID$(inSTG$, last + 1, st - last - 1) '       | Return requested word.
  DONE: '                                               | Label for bail destination of word count error check.
END FUNCTION '                                          | End of function.

Quackery

  [ [] [] rot
    witheach 
    [ dup char , = iff
        [ drop nested join [] ]
      else join ]
    nested join ]                is tokenise ( $ --> [ )
 
  [ witheach [ echo$ say "." ] ] is display  ( [ -->   )
 
  $ "Hello,How,Are,You,Today" tokenise display
Output:
Hello.How.Are.You.Today.

R

text <- "Hello,How,Are,You,Today"
junk <- strsplit(text, split=",")
print(paste(unlist(junk), collapse="."))

or the one liner

paste(unlist(strsplit(text, split=",")), collapse=".")

Racket

#lang racket
(string-join (string-split "Hello,How,Are,You,Today" ",") ".")
;; -> "Hello.How.Are.You.Today"

Raku

(formerly Perl 6)

Works with: Rakudo version #22 "Thousand Oaks"
'Hello,How,Are,You,Today'.split(',').join('.').say;

Or with function calls:

say join '.', split ',', 'Hello,How,Are,You,Today';

Raven

'Hello,How,Are,You,Today' ',' split '.' join print

REBOL

print ["Original:"  original: "Hello,How,Are,You,Today"]
tokens: parse original ","
dotted: ""  repeat i tokens [append dotted rejoin [i "."]]
print ["Dotted:  "  dotted]
Output:
 Original: Hello,How,Are,You,Today
 Dotted:   Hello.How.Are.You.Today.

Red

str: "Hello,How,Are,You,Today"
>> tokens: split str ","
>> probe tokens
["Hello" "How" "Are" "You" "Today"]

>> periods: replace/all form tokens " " "."        ;The word FORM converts the list series to a string removing quotes. 
>> print periods                                            ;then REPLACE/ALL spaces with period
Hello.How.Are.You.Today

Retro

{{
  : char     (  -$  )   " " ;
  : tokenize ( $-$$ )
    @char ^strings'splitAtChar withLength 1- over + 0 swap ! tempString ;
  : action   ( $-   )
    keepString ^buffer'add ;
---reveal---
  : split    ( $cb- )
    ^buffer'set !char
    char ^strings'append
    [ tokenize action dup 1 <> ] while drop
    ^buffer'get drop ;
}}

This will suffice to split a string into an array of substrings. It is used like this:

create strings 100 allot
"Hello,How,Are,You,Today" ', strings split

Since the buffer' vocabulary creates a zero-terminated buffer, we can display it using the each@ combinator and a simple quote:

strings [ @ "%s." puts ] ^types'STRING each@

REXX

version 1

This REXX version doesn't append a period to the last word in the list.

/*REXX program separates a string of comma─delimited words, and echoes them ──► terminal*/
original = 'Hello,How,Are,You,Today'             /*some words separated by commas (,).  */
say  'The input string:'  original               /*display original string ──► terminal.*/
new= original                                    /*make a copy of the string.           */
                 do #=1  until  new==''          /*keep processing until  NEW  is empty.*/
                 parse var  new   @.#  ','  new  /*parse words delineated by a comma (,)*/
                 end   /*#*/                     /* [↑]  the new array is named   @.    */
say                                              /* NEW  is destructively parsed.   [↑] */
say center(' Words in the string ', 40, "═")     /*display a nice header for the list.  */
                 do j=1  for #                   /*display all the words (one per line),*/
                 say @.j || left(., j\==#)       /*maybe append a period (.) to a word. */
                 end   /*j*/                     /* [↑]  don't append a period if last. */
say center(' End─of─list ', 40, "═")             /*display a (EOL) trailer for the list.*/
output   when using the internal default input:
The input string: Hello,How,Are,You,Today

═════════ Words in the string ══════════
Hello.
How.
Are.
You.
Today
═════════════ End─of─list ══════════════

version 2

This REXX version won't work if any of the words have an embedded blank (or possible a tab character) in them, as in:

Hello,Betty Sue,How,Are,You,Today

/*REXX program to separate a string of comma-delimited words and echo */
sss='Hello,How,Are,You,Today'
say 'input string='sss
say ''
say 'Words in the string:'
ss =translate(sss,' ',',')
dot='.'
Do i=1 To words(ss)
  If i=words(ss) Then dot=''
  say word(ss,i)dot
  End
say 'End-of-list.'

output is similar to REXX version 1.

Ring

see substr("Hello,How,Are,You,Today", ",", ".")

RPL

The program below fully complies with the task requirements, e.g. the input string is converted to a list of words, then the list is converted to a string.

Works with: Halcyon Calc version 4.2.8
RPL code Comment
 ≪ 
  "}" + "{" SWAP + STR→ 
  1 OVER SIZE FOR j 
     DUP j GET →STR 2 OVER SIZE 1 - SUB j SWAP PUT 
  NEXT
  "" 1 3 PICK SIZE FOR j 
     OVER j GET + 
     IF OVER SIZE j ≠ THEN "." + END 
  NEXT SWAP DROP
≫ 'TOKNZ' STO
TOKNZ ( "word,word" → "word.word" ) 
convert string into list (words being between quotes)
loop for each list item
  convert it to a string, remove quotes at beginning and end

loop for each list item
  add item to output string
  if not last item, append "."
clean stack
return output string
"Hello,How,Are,You,Today" TOKNZ

Output:

 1: "Hello.How.Are.You.Today"

If direct string-to-string conversion is allowed, then this one-liner for HP-48+ will do the job:

≪ 1 OVER SIZE FOR j IF DUP j DUP SUB "," == THEN j "." REPL END NEXT ≫ 'TOKNZ' STO

Ruby

puts "Hello,How,Are,You,Today".split(',').join('.')

Rust

fn main() {
    let s = "Hello,How,Are,You,Today";
    let tokens: Vec<&str> = s.split(",").collect();
    println!("{}", tokens.join("."));
}

S-lang

variable a = strchop("Hello,How,Are,You,Today", ',', 0);
print(strjoin(a, "."));
Output:
"Hello.How.Are.You.Today"

Scala

println("Hello,How,Are,You,Today" split "," mkString ".")

Scheme

Works with: Guile
(use-modules (ice-9 regex))
(define s "Hello,How,Are,You,Today")
(define words (map match:substring (list-matches "[^,]+" s)))

(do ((n 0 (+ n 1))) ((= n (length words)))
        (display (list-ref words n))
        (if (< n (- (length words) 1))
                (display ".")))

(with SRFI 13)

(define s "Hello,How,Are,You,Today")
(define words (string-tokenize s (char-set-complement (char-set #\,))))
(define t (string-join words "."))
Works with: Gauche Scheme
(print
  (string-join
    (string-split "Hello,How,Are,You,Today" #\,)
    "."))
Output:
Hello.How.Are.You.Today

Seed7

var array string: tokens is 0 times "";

tokens := split("Hello,How,Are,You,Today", ",");

Self

| s = 'Hello,How,Are,You,Today' |
((s splitOn: ',') joinUsing: '.') printLine.

Sidef

'Hello,How,Are,You,Today'.split(',').join('.').say;

Simula

BEGIN

    CLASS TEXTARRAY(N); INTEGER N;
    BEGIN
        TEXT ARRAY ARR(1:N);
    END TEXTARRAY;

    REF(TEXTARRAY) PROCEDURE SPLIT(T,DELIM); TEXT T; CHARACTER DELIM;
    BEGIN
        INTEGER N, I, LPOS;
        REF(TEXTARRAY) A;

        N := 1;
        T.SETPOS(1);
        WHILE T.MORE DO
            IF T.GETCHAR = DELIM THEN
                N := N+1;
        A :- NEW TEXTARRAY(N);

        I := 0;
        LPOS := 1;
        T.SETPOS(LPOS);
        WHILE T.MORE DO
            IF T.GETCHAR = DELIM THEN
            BEGIN
                I := I+1;
                A.ARR(I) :- T.SUB(LPOS,T.POS-LPOS-1);
                LPOS := T.POS;
            END;
        I := I+1;
        A.ARR(I) :- T.SUB(LPOS,T.LENGTH-LPOS+1);
        SPLIT :- A;
    END SPLIT;

    BEGIN
        TEXT S;
        REF(TEXTARRAY) TA;
        INTEGER I;

        S :- "HELLO,HOW,ARE,YOU,TODAY";
        TA :- SPLIT(S,',');
        FOR I := 1 STEP 1 UNTIL TA.N DO
        BEGIN
            OUTTEXT(TA.ARR(I));
            OUTCHAR('.');
        END;
        OUTIMAGE;
    END;

END.
Output:
HELLO.HOW.ARE.YOU.TODAY.

Slate

('Hello,How,Are,You,Today' splitWith: $,) join &separator: '.'.

Slope

(display
  (list->string
    (string->list
      "Hello,How,Are,You,Today"
      ",")
    "."))
Output:
Hello.How.Are.You.Today

Smalltalk

|array |
array := 'Hello,How,Are,You,Today' subStrings: $,.
array fold: [:concatenation :string | concatenation, '.', string ]

Some implementations also have a join: convenience method that allows the following shorter solution:

('Hello,How,Are,You,Today' subStrings: $,) join: '.'

The solution displaying a trailing period would be:

|array |
array := 'Hello,How,Are,You,Today' subStrings: $,.
array inject: '' into: [:concatenation :string | concatenation, string, '.' ]

SNOBOL4

For this task, it's convenient to define Perl-style split( ) and join( ) functions.

        define('split(chs,str)i,j,t,w2') :(split_end)
split   t = table()
sp1     str pos(0) (break(chs) | rem) $ t<i = i + 1>
+           span(chs) (break(chs) | '') . w2  = w2 :s(sp1)
*       t<i> = differ(str,'') str ;* Uncomment for CSnobol
        split = array(i)
sp2     split<j = j + 1> = t<j> :s(sp2)f(return)
split_end

        define('join(ch,a)i,') :(join_end)
join    join = join a<i = i + 1>
        join = join ?a<i + 1> ch :s(join)f(return)
join_end

*       # Test and display
        output = join('.',split(',','Hello,How,Are,You,Today'))
end
Output:
 Hello.How.Are.You.Today

Standard ML

val splitter = String.tokens (fn c => c = #",");
val main = (String.concatWith ".") o splitter;

Test:

- main "Hello,How,Are,You,Today"
val it = "Hello.How.Are.You.Today" : string

Swift

Works with: Swift version 3.x
let text = "Hello,How,Are,You,Today"
let tokens = text.components(separatedBy: ",") // for single or multi-character separator
print(tokens)
let result = tokens.joined(separator: ".")
print(result)
Works with: Swift version 2.x
let text = "Hello,How,Are,You,Today"
let tokens = text.characters.split(",").map{String($0)} // for single-character separator
print(tokens)
let result = tokens.joinWithSeparator(".")
print(result)
Works with: Swift version 1.x
let text = "Hello,How,Are,You,Today"
let tokens = split(text, { $0 == "," }) // for single-character separator
println(tokens)
let result = ".".join(tokens)
println(result)

For multi-character separators:

import Foundation

let text = "Hello,How,Are,You,Today"
let tokens = text.componentsSeparatedByString(",")
print(tokens)

Tcl

Generating a list form a string by splitting on a comma:

split $string ","

Joining the elements of a list by a period:

join $list "."

Thus the whole thing would look like this:

puts [join [split "Hello,How,Are,You,Today" ","] "."]

If you'd like to retain the list in a variable with the name "words", it would only be marginally more complex:

puts [join [set words [split "Hello,How,Are,You,Today" ","]] "."]

(In general, the regexp command is also used in Tcl for tokenization of strings, but this example does not need that level of complexity.)

tr

tr knows nothing about arrays, so this solution only changes each comma to a period.

echo 'Hello,How,Are,You,Today' | tr ',' '.'

Transd

#lang transd

MainModule: {
_start: (lambda locals: s "Hello,How,Are,You,Today"
    (textout (join (split s ",") "."))
)
}
Output:
Hello.How.Are.You.Today

TUSCRIPT

$$ MODE TUSCRIPT
SET string="Hello,How,Are,You,Today"
SET string=SPLIT (string,":,:")
SET string=JOIN  (string,".")

TXR

Collecting tokens which consist of non-empty sequences of non-commas.

@(next :list "Hello,How,Are,You,Today")
@(coll)@{token /[^,]+/}@(end)
@(output)
@(rep)@token.@(last)@token@(end)
@(end)

Different approach. Collect tokens, each of which is a piece of text which either terminates before a comma, or else extends to the end of the line.

@(next :list "Hello,How,Are,You,Today")
@(coll)@(maybe)@token,@(or)@token@(end)@(end)
@(output)
@(rep)@token.@(last)@token@(end)
@(end)

Using TXR Lisp:

txr -p '(cat-str (split-str "Hello,How,Are,You,Today" ",") ".")'
Hello.How.Are.You.Today

UNIX Shell

Works with: Bourne Shell
string='Hello,How,Are,You,Today'

(IFS=,
 printf '%s.' $string
 echo)

Works with: Bourne Again SHell
Works with: Public Domain Korn SHell version 5.2.14
#! /bin/bash
stripchar-l ()
#removes the specified character from the left side of the string
#USAGE: stripchar "stuff" "s" --> tuff 
{ 
    string="$1";
    string=${string#"$2"};
    
  echo "$string"
}

join ()
#join a string of characters on a specified delimiter
#USAGE: join "1;2;3;4" ";" "," --> 1,2,3,4
{ 
    local result="";
    local list="$1";
    OLDIFS="$IFS";
    local IFS=${2-" "}; 
    local output_field_seperator=${3-" "};
    
    for element in $list;
    do
        result="$result$output_field_seperator$element";
    done;
    
    result="`stripchar-l "$result" "$output_field_seperator"`";
    echo "$result";
    IFS="$OLDIFS"
}

split () 
{ 
#split a string of characters on a specified delimiter
#USAGE: split "1;2;3;4" ";" --> 1 2 3 4	
    local list="$1";
    local input_field_seperator=${2-" "}; 
    local output_field_seperator=" ";
    
  #defined in terms of join
  join "$list" "$input_field_seperator" "$output_field_seperator"
}

strtokenize () 
{
#splits up a string of characters into tokens,
#based on a user supplied delimiter
#USAGE:strtokenize "1;2;3;4" ";" ":" --> 1:2:3:4
    local list="$1";
	local input_delimiter=${2-" "}; 
	local output_delimiter=${3-" "};
	local contains_a_space=" "; #added to highlight the use
                                    #of " " as an argument to join	
  
  #splits it input then joins it with a user supplied delimiter
  join "$( split "$list" "$input_delimiter" )" \
    "$contains_a_space" "$output_delimiter"; 
}

Example

 strtokenize "Hello,How,Are,You,Today" "," "." 
            Hello.How.Are.You.Today

Works with: Almquist Shell
Works with: bash
Works with: pdksh
Works with: ksh93
Works with: zsh
string1="Hello,How,Are,You,Today"
elements_quantity=$(echo $string1|tr "," "\n"|wc -l)

present_element=1
while [ $present_element -le $elements_quantity ];do
echo $string1|cut -d "," -f $present_element|tr -d "\n"
if [ $present_element -lt $elements_quantity ];then echo -n ".";fi
present_element=$(expr $present_element + 1)
done
echo

# or to cheat
echo "Hello,How,Are,You,Today"|tr "," "."

UnixPipes

Works with: Bourne Shell
token() {
   (IFS=, read -r A B; echo "$A".; test -n "$B" && (echo "$B" | token))
}

echo "Hello,How,Are,You" | token

Ursa

decl string text
set text "Hello,How,Are,You,Today"
decl string<> tokens
set tokens (split text ",")
for (decl int i) (< i (size tokens)) (inc i)
        out tokens<i> "." console
end for
out endl console

Ursala

A list of strings is made by separating at the commas using the library function, sep. A single string is then made by joining the list of strings with periods using the library function, mat. Each of these is a second order function parameterized by the delimiter. Character literals are preceded by a backquote.

#import std

token_list = sep`, 'Hello,How,Are,You,Today'

#cast %s

main = mat`. token_list
Output:
 'Hello.How.Are.You.Today'

Vala

void main() { 
  string s = "Hello,How,Are,You,Today";
  print(@"$(string.joinv(".", s.split(",")))");
}
Output:
Hello.How.Are.You.Today

VBA

Sub Main()
Dim temp() As String
   temp = Tokenize("Hello,How,Are,You,Today", ",")
   Display temp, Space(5)
End Sub

Private Function Tokenize(strS As String, sep As String) As String()
   Tokenize = Split(strS, sep)
End Function

Private Sub Display(arr() As String, sep As String)
   Debug.Print Join(arr, sep)
End Sub
Output:
Hello     How     Are     You     Today

VBScript

s = "Hello,How,Are,You,Today"
WScript.StdOut.Write Join(Split(s,","),".")
Output:
Hello.How.Are.You.Today

Vedit macro language

Vedit does not use the concepts of array or list. Normally, the text is processed as text in an edit buffer.

However, this example shows how to split the text into multiple text registers (10, 11, 12 etc.). The contents of each text register is then displayed to user, separated by a period.

Buf_Switch(Buf_Free)
Ins_Text("Hello,How,Are,You,Today")

// Split the text into text registers 10, 11, ...
BOF
#1 = 9
Repeat(ALL) {
    #1++
    #2 = Cur_Pos
    Search(",", ADVANCE+ERRBREAK)
    Reg_Copy_Block(#1, #2, Cur_Pos-1)
}
Reg_Copy_Block(#1, #2, EOB_Pos)

// Display the list
for (#3 = 10; #3 <= #1; #3++) {
    Reg_Type(#3) Message(".") 
}

Buf_Quit(OK)

V (Vlang)

// Tokenize a string, in V (Vlang)
// Tectonics: v run tokenize-a-string.v
module main

// starts here
pub fn main() {
    println("Hello,How,Are,You,Today".split(',').join('.'))
}
Output:
prompt$ v run rosetta/tokenize-a-string.v
Hello.How.Are.You.Today

WinBatch

text  = 'Hello,How,Are,You,Today'
result = ''
BoxOpen('WinBatch Tokenizing Example', '')
for ix = 1 to itemcount(text,',')
    result = result : itemextract(ix, text, ',') : '.'
    BoxText(result)
next
display(10, 'End of Program', 'Dialog and program will close momentarily.')
BoxShut()
Output:
Hello.How.Are.You.Today.

Wortel

@join "." @split "," "Hello,How,Are,You,Today"

Returns

"Hello.How.Are.You.Today"

Wren

var s = "Hello,How,Are,You,Today"
var t = s.split(",").join(".") + "."
System.print(t)
Output:
Hello.How.Are.You.Today.

XPath 2.0

string-join(tokenize("Hello,How,Are,You,Today", ","), ".")
Output:
Hello.How.Are.You.Today

XPL0

string 0;
include c:\cxpl\codes;
int  I, J, K, Char;
char String, Array(5,6);        \5 words and 5 maximum chars + terminating 0

[String:= "Hello,How,Are,You,Today";
I:= 0;  K:= 0;
repeat  J:= 0;
        loop    [Char:= String(I);
                I:= I+1;
                if Char=^, or Char=0 then quit;
                Array(K,J):= Char;
                J:= J+1;
                ];
        Array(K,J):= 0;         \terminate word
        K:= K+1;                \next word in array
until   K>=5;
for K:= 4 downto 0 do [Text(0, addr Array(K,0));  ChOut(0, ^.)];
CrLf(0);
]

The 'addr' operator is used to fetch the 32-bit address of Array rather than a byte from the character array.

Output (done in reverse order to emphasize the tokens are indeed separate):

Today.You.Are.How.Hello.

Yabasic

dim s$(1)

n = token("Hello. How are you today?", s$(), ".? ")

for i = 1 to n
	print s$(i);
	if i < n print ".";
next
print

Zig

const std = @import("std");
pub fn main() void {
  const string = "Hello,How,Are,You,Today";
  var tokens = std.mem.split(u8, string, ",");
  std.debug.print("{s}", .{tokens.next().?});
  while (tokens.next()) |token| {
    std.debug.print(".{s}", .{token});
  }
}

zkl

"Hello,How,Are,You,Today".split(",").concat(".").println();
Hello.How.Are.You.Today

Zoea

program: tokenize_a_string
  input: "Hello,How,Are,You,Today"
  output: "Hello.How.Are.You.Today"

Zoea Visual

Tokenize a string

Zsh

str='Hello,How,Are,You,Today'
tokens=(${(s:,:)str})
print ${(j:.:)tokens}

Or, using SH_SPLIT_WORD:

str='Hello,How,Are,You,Today'
IFS=, echo ${(j:.:)${=str}}