Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tokenize string with zero length components
#3
Dear Gintaras, many thanks indeed. Let me attach my approach. It is implied that yours is elegant and powerful. Best regards.

Function tempf12
Code:
Copy      Help
str subject="`164```````````````123```"

str pattern="`"
ARRAY(str) arr
int i i0 i1 nt
ARRAY(CHARRANGE) a
nt=findrx(subject pattern 0 4 a)
;s.get(subject 29 43-29)
;out s
out nt
if nt=0; ret
arr.create(nt+1)

;1st Element
i0=a[0 0].cpMax
arr[0].get(subject  0 i0-1)

;Subsequent Elements
for i 0 a.len-1
,i0=a[0 i].cpMax
,i1=a[0 i+1].cpMin
,arr[i+1].get(subject  i0 i1-i0)
;,out F"{i} {i0} {i1} {s}"

for i 0 arr.len
,out F"{i} {arr[i]}"


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)