Here's simple function that gets you part way: A console session follows:
>> u1: "www.somewhere.com&blah-blah"
== "www.somewhere.com&blah-blah"
>> u2: "www.somewhere.com-extrapathbit&blah-blah"
== "www.somewhere.com-extrapathbit&blah-blah"
>> chpurl: func [s[string!]][
[ parse first parse s "&" "-"]
>> chpurl u1
== ["www.somewhere.com"]
>> chpurl u2
== ["www.somewhere.com" "extrapathbit"]
>>
Outlook express has inserted underlines for the URL's above; ignore them.
Also, the >> and [ above at the start of the lines are console session
prompts.
Russell [EMAIL PROTECTED]
Russell [EMAIL PROTECTED]
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, September 16, 2000 7:42 AM
Subject: [REBOL] small parse problem Re:
> Hi, Anton!
>
> I think this does what you want.
>
> >> chopurl: func [s [string!] /local part1 part2 urlchopper] [
> [ urlchopper: [
> [ [
> [ copy part1 to "-" skip copy part2 to "&"
> [ |
> [ copy part1 to "&" (part2: copy "")
> [ ]
> [ to end
> [ ]
> [ parse/all s urlchopper
> [ print [mold part1 mold part2]
> [ ]
> >> chopurl "www.somewhere.com&blah-blah"
> "www.somewhere.com" ""
> >> chopurl "www.somewhere.com-extrapathbit&blah-blah"
> "www.somewhere.com" "extrapathbit"
> >>
>
> -jn-
>
> [EMAIL PROTECTED] wrote:
> >
> > Hi,
> >
> > I want to parse some input like this:
> > "www.somewhere.com&blah-blah" OR
> > "www.somewhere.com-extrapathbit&blah-blah".
> >
> > How can I parse up to the hyphen (if it's there) making sure it's before
> > the ampersand?
> > The ampersand tells me it's the end of the url. So I don't want to parse
> > all the way thru "blah".
> >
> > My two outputs should be, respectively:
> > "www.somewhere.com" "" OR
> > "www.somewhere.com" "extrapathbit"
> >
> > Please help!
> >
> > Anton.
>