split() function (like perl's) - Reply
- Posted by "BABOR, JIRI" <J.Babor at GNS.CRI.NZ> Jul 08, 1998
- 489 views
-- split.ex -- j.babor at gns.cri.nz -- 98-07-08 function split(integer c, sequence s) -- split string s using c as de-limiter sequence os integer i,j,inword os={} inword=0 j=1 while j<=length(s) do if inword then if s[j]=c then os=append(os,s[i..j-1]) inword=0 end if elsif s[j]!=c then i=j inword=1 end if j=j+1 end while if inword then os=append(os,s[i..j-1]) end if return os end function ? split(' ',"") ? split(' '," ") ? split(' ',"Viva Euphoria !") ? split(' '," Viva Euphoria ! ")