Hi Gabriele,

You wrote:

>>> text: "this is a testament to be searched"
>== "this is a testament to be searched"
>>> parse/all text [
>[    to "t" mark1: skip
>[    any [
>[        "t" mark2: " " to end |
>[        no-space |
>[        to "t" mark1: skip
>[        ]
>[    ]
>== true
>>> copy/part mark1 mark2
>== "testament"

That's really good - another technique I'll try to absorb. Unfortunately,
though, I wanted the first "t" to be the first character in a word. Your rule
will succeed with strings like "this is a nontext to be searched" - which I
didn't want to match. It also succeeds with the string "splat" (although
mark2 doesn't get set).

The most reliable solution I can find is (using a technique I learned from
you):

rule: [
    mark0:
    some [
        space mark1: "t" some [
            "t" mark2: [ space to end | end ] mark0: | no-space
        ] | skip
    ]
    :mark0
]

I think it's safe to say this is too complex for general use. I shudder to
think what would be involved trying to generate such a rule.

And ...

Hi Cheryl,

You wrote:

>What is SEARCH? Is is available at rebol.org? I looked and did not see it
>there.

Sorry, I haven't put it there. It's more of a proof-of-concept rather than a
practical solution. It's just a simulation of regular expression behavior
(including backtracking) with expressions that look like PARSE rules.

I'll try to make the code a bit more presentable and post it to rebol.org
or the list in a couple of days.

Thanks for asking!

Eric

Reply via email to