07-30-2009, 01:41 AM
I don't think I understand tok function delimiter.
Can a string serve as a single token (not as a table of delimiters but as a single delimiter).
Can I use "name" as a delimeter in s2 to get same output as using "|" as delimiter in s1?
ie: how to get the same output from example 1 as in example 2?
example 1
------------------
str s1="joe | daniel | megan | joan"
ARRAY(str) arr1
int i nt
nt = tok(s1 arr1 -1 "|" 4)
for(i 0 nt) out arr1[i]
-----output: ----------------
joe
daniel
megan
joan
out "----------------------------------------------------"
example 2
------------------
str s2="joe name daniel name megan name joan"
ARRAY(str) arr2
nt = tok(s2 arr2 -1 "name" 4)
for(i 0 nt) out arr2[i]
-----output: ----------------
jo
d
i
l
g
jo
Can a string serve as a single token (not as a table of delimiters but as a single delimiter).
Can I use "name" as a delimeter in s2 to get same output as using "|" as delimiter in s1?
ie: how to get the same output from example 1 as in example 2?
example 1
------------------
str s1="joe | daniel | megan | joan"
ARRAY(str) arr1
int i nt
nt = tok(s1 arr1 -1 "|" 4)
for(i 0 nt) out arr1[i]
-----output: ----------------
joe
daniel
megan
joan
out "----------------------------------------------------"
example 2
------------------
str s2="joe name daniel name megan name joan"
ARRAY(str) arr2
nt = tok(s2 arr2 -1 "name" 4)
for(i 0 nt) out arr2[i]
-----output: ----------------
jo
d
i
l
g
jo