[EMAIL PROTECTED] wrote:
> 
> Phil wrote:
> > Is there a built Rebol function that does the equivalent of Java's
> > substring??
> 
> Have a look at 'copy, in particular, the '/part refinement.
> 

Just to gild the lilly...

Since substr[ing] in various languages usually involves both an
an offset into the original string and a length (or first and last
offsets, which by arithmetic are the same thing), we can make nice
and define (re-formatted for appearance)

    >> subser: func [
           s [series!] pass [integer!] keep [integer!]
       ][
           copy/part skip s pass keep
       ]
    >> sample: "this is a (somewhat) very long string"
    == "this is a (somewhat) very long string"
    >> index? find sample " ("
    == 10
    >> subser sample 10 10
    == "(somewhat)"

-jn-

Reply via email to