Hi Chris, 

Christopher Ross-Gill wrote:
> 
> Hi,
> 
> >    join word-split "hellotherethisisanexample" "this"
> > == "hellothereisanexample"
> 
> >> rejoin word-split "hellotherethisisanexample" "this"
> == "hellothereisanexample"
> 
> I'm sure there's a more elegant way to do it than my effort below, or one
> that splits the string at all instances of the word...
> 
> - Chris
> 
> --
> REBOL []
> 
> word-split: func [
>     string [string!] word [string!] /local first second
> ][
>     if not second: find string word [return reduce [string]]
>     first: copy/part string second
>     second: copy skip second length? word
>     return reduce [first second]
> ]

I would do it like that :

word-split: func [text [string!] value [string!] /local fst snd][
    parse text [to value s: (fst: copy/part txt s) value s: (snd: copy
s)]
    reduce [fst snd]
]

or 

word-split: func [text [string!] value [string!] /local pos][
    reduce [copy/part text pos: find text value copy skip pos length?
value]
]

which would make my java-addicted friends say: "REBOL has a really bad
syntax" ! ;-)


-DocKimbel
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to