Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
delimiter in tok
#1
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
#2
String cannot be delimiter.

You can at first replace all " name " to "|", then use tok with "|".


Forum Jump:


Users browsing this thread: 1 Guest(s)