These cases might also be informative:

>> parse " the  radio " ["the" "radio" any space]
== true
>> parse " the   radio   " [thru "the" "radio" to end]
== true
>> parse " the big radio " [thru "the" "radio" to end]
== false

Seems (to me) when there is no space following "radio" (in the string being
parsed) it reaches the end and considers the result matched.  When there IS
a space(s) it includes the space(s) in the match and doesn't find one.

 I agree, it's kinda disconcerting that it works differently at the
beginning, middle, end of a string.  I'm sure someone at REBOL could answer
it more precisely (hope they will). :)

Russ

-----------  
At 05:04 PM 10/8/99 +0100, you wrote:
>
>
>[EMAIL PROTECTED] wrote:
>
>> Hi
>> The question:
>>
>> Why if
>>         parse "the radio" ["the" "radio"]
>>         parse "the         radio" ["the" "radio"]
>>         parse "       the         radio" ["the" "radio"]
>>
>> are all true,
>>
>>         parse "       the         radio " ["the" "radio"]
>>
>> is false?
>
>I think it's because of how rules are applied. The first rule says, -
>does "the" matches the input string? If so, it ignores spaces, and tries
>to do second part of your rule, so it tries to match "radio".
>
>Try this:
>
>space: #" "
>parse "     the     radio" [any space "the" "radio"]
>
>;hmm, I thought even "some space" should work, but it doesn't. It also
>count for the space at the end of the string:
>
>space: #" "
>parse "     the     radio  " [any space "the" "radio" any space] ;or
>
>space: #" "
>parse "     the     radio" [any space "the" "radio" to end] ; or
>
>space: #" "
>parse "     the     radio" [thru "the" "radio" to end]
>
>but i think parse should ignore spaces in the beginning and in the end
>of the string, as it ignores them between the words. Or just use trim on
>your string:
>
>->> parse trim "     the     radio " ["the" "radio"]
>== true
>
>Hope this helps,
>
>Regards,
>
>-pekr-
>
>>
>>
>> Thank you
>>
>> --
>> Luis Marzulli
>> e-mail: [EMAIL PROTECTED]
>> Caracas, VENEZUELA

Reply via email to