[REBOL] Re: Parse question
From: tim:johnsons-web at: 26-Jul-2003 8:13
* Romano Paolo Tenca <[rotenca--telvia--it]> [030726 03:07]:
> > 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
Of course! Why didn't I think of that?
I've had this code for several versions...
Thanks Romano.
~tj~
> ---
> Ciao
> Romano
>
> --
> To unsubscribe from this list, just send an email to
> [rebol-request--rebol--com] with unsubscribe as the subject.
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com
http://www.johnsons-web.com