[EMAIL PROTECTED] wrote:
> Hi Eric, 7-Jan-2000 you wrote:
>
> >Ole, you suggested this to find a word ending in "ing":
>
> >>> a: [skip a | "ing"]
> >== [skip a | "ing"]
> >>> parse "ringin" a
> >== false
> >>> parse "ringing" a
> >== true
>
> >That's fine, except it won't detect a word ending in "ing" in the
> >middle of the string:
>
> >>> parse "ringing bells" a
> >== false
>
> Ah, then I just got you wrong. The easy way to do the above is first to split
> the text up with
>
> parse str none
>
> and then match the individual words. However, this should work too:
>
> sep: charset " ,.!?" ; and whatever else you want to split up words
> b: [skip b | "ing"]
> a: [b | to "ing" [sep to end | a]]
> parse str a
>
> though it's completely untested, and I agree that it's ugly :-)
This will not work imho :-)
as for "ringing bells"
Again, you are going to reach end of the string, then going back recursively
until first "ing" (applied from end of the string) is not matched. :
>> b: [skip markb: (print ["markb: " markb index? markb]) b | back-b: (print
["back-b: " back-b in
dex? back-b]) "ing"]
== [skip markb: (print ["markb: " markb index? markb]) b | back-b: (print
["back-b: " back-b index
? back-b]) "ing"]
>> parse str a
markb: inging bells 2
markb: nging bells 3
markb: ging bells 4
markb: ing bells 5
markb: ng bells 6
markb: g bells 7
markb: bells 8
markb: ells 10
markb: lls 11
markb: ls 12
markb: s 13
markb: 14
back-b: 14
back-b: s 13
back-b: ls 12
back-b: lls 11
back-b: ells 10
back-b: bells 9
back-b: g bells 7
back-b: ng bells 6
back-b: ing bells 5
== false
Your code will fail with something like "ringing sounding bell" ... it will match
sounding, so generally said - the last occurance of "ing" contained in the string
...
And because of that, second part of 'a - {to "ing" [sep to end | a]}will be NEVER
applied, as your pointer is just behind last occurance of "ing" contained in your
string ... that's why you got false result.
change 'a to [b to end] and once succesfully back from 'b, it will continue "to
end" and return "true" ...
Cheers,
-pekr-
>
> Kind regards,
> --
> Ole Friis <[EMAIL PROTECTED]>
>
> "Ignorance is bliss"
> (Cypher, The Matrix)