[REBOL] Re: Find? Copy/Part?
From: volker:nitsch:gma:il at: 18-Jan-2005 23:56
On Tue, 18 Jan 2005 15:05:40 -0200, Carlos Lorenz
<[carlos--lorenz--gmail--com]> wrote:
> Ingo,
>
> Thanks for you reply.
>
> I dir not think about parse though I can see you solve it using it.
>
> Parse yet has a not so confortable sintax to me so I try to avoid the
> use of it most part of the time.
>
> I'd like to have something just like I get in Visual Fox Pro. See below:
>
> * ------------------------------------------
> a = "aaa*aaa*aaa*aaa"
>
> * gets the second ocurrence of "*" in the string from left to right
> pos = at( "*" , a , 2)
>
> * then asking VFP to grab a piece of the string up to the
> * second "*" in the string a
> ? left(a,pos)
>
> * gives the result
> aaa*aaa*
> * -------------------------------------------
>
Your main problem is, you gave 'parse no chance to be good in your question. ;)
if you had given this spec immediate, its easier. because we can drop
this ugly position-handling.
str: "aaa*bbb*ccc*ddd"
parse str[ copy start [ 2 thru "*" ] ]
probe start
;== "aaa*bbb*"
Or more verbose:
parse str[
copy start ; copy stuff in 'start for the following expr.
[
2 thru "*" ; the "regular expression" telling what to include
]
]
> Would it be very nice to have an AT-like native function in
> REBOL/Core, don't you think so?
>
No :)
--
-Volker
Any problem in computer science can be solved with another layer of
indirection. But that usually will create another problem.
David
Wheeler