问题
See similar question for string case.
In R3-Alpha, I tried to adapt the @sqlab response to block case:
parse [x x x x #[none] a #[none] #[none] b] [to [none! none!] ??]
I expect ??: [#[none] #[none] b]
, but get
** Script error: PARSE - invalid rule or usage of rule: none!
It's the result right and my expectation wrong? Or it's a bug?
回答1:
I can just show a solution for Red and Rebol2. As the words in the rule are reduced automatic, you have to shield them.
Red
>> parse [x x x x _ a _ _ b] [to [ '_ '_] y: ]
== false
>>
>> y
== [_ _ b]
Rebol2
>> parse [x x x x _ a _ _ b] [some [r: [ '_ '_ ] (y: r) | skip] ]
== true
>> y
== [_ _ b]
After the editing of the question by HostileFork the solution for Red looks like that
>> parse [x x x x #[none] a #[none] #[none] b] [to [none! none!] y:]
== false
>> y
== [none none b]
>>
example according the question in the comment of giuliolunati
>> parse [x x x x 0 a 1 2 b] [to [integer! integer!] y:]
== false
>> y
== [1 2 b]
来源:https://stackoverflow.com/questions/54577826/rebol-parse-rule-to-match-to-first-occurrence-of-at-least-2-nones