[REBOL] Re: Parse question
From: rotenca:telvia:it at: 26-Jul-2003 12:53
> 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?
why not?
parse/all str to-string delimiters
---
Ciao
Romano