[REBOL] Parse question
From: tim:johnsons-web at: 25-Jul-2003 17:10
I have the following code:
str2blk: func[str[string!] delimiters[string! char!]
/local non-delims blk txt delims] [
if char? delimiters[delimiters: to-string delimiters]
delims: charset delimiters
non-delims: complement delims
blk: copy []
parse/all str[some [copy txt some non-delims (insert tail blk txt) | delims]]
return blk
];end function --------------------
>> str2blk "bcadefafg" "a"
== ["bc" "def" "fg"] ; that's good
; but where
>> str2blk "bcadeaafg" "a"
== ["bc" "de" "fg"] ; not good, I'd like
; to see
== ["bc" "de" "" "fg"]
IOWs, where there are two consecutive delimiters,
I would like an empty string inserted.
any Ideas?
Thanks
tim
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com
http://www.johnsons-web.com