A warning up front: there are many different ways to achieve this in Rebol. So you'll probably get quite a few different suggestions.
For a start, let's stick to your original approach of using FIND.
When you use FIND with a series, what you get is a new view onto the underlying series data, positioned at a different offset from the start of the series data.
Let's start with some example data:
>> line: copy "this is foo#and here comes a long bar"
== "this is foo#and here comes a long bar"
Let's FIND the #
character within that line, and refer to the result as POS:
>> pos: find line "#"
== "#and here comes a long bar"
As you can see, this basically already gives you the second part (what you called REST2) of your split. You'll only have to skip past the delimiter itself (and then copy the resulting string, to make it independent from the original LINE string):
>> rest: copy next pos
== "and here comes a long bar"
For extracting the initial part, you can use a nice feature of COPY/part. The documentation of the "/part" refinement (try help copy
) says: "Limits to a given length or position" (emphasis mine). We already have that position handy as POS. So:
>> ref: copy/part line pos
== "this is foo"
And there you go! The complete code:
pos: find line "#"
ref: copy/part line pos
rest: copy next pos
For reference, here's a PARSE-based approach:
parse line [copy ref to "#" skip copy rest to end]
I'll let this stand without further explanation. If you want to know more about PARSE, a good place to start is the venerable "Parsing" chapter in the REBOL/Core Users Guide (originally written for REBOL 2.3, but the basics are still mostly the same in current REBOL 2 and 3 versions).
One ancillary note at the end: instead of a single-item string "#"
you could also use a character which is written as #"#"
in Rebol.