Rebol PARSE rule to match thru first occurrence of

2019-07-24 15:27发布

问题:

rule: [while [not ["--"] skip] some "-"] parse "a-bc----d" [rule ??]

prints

??: "d"

But I need a more efficient rule (e.g. using to #"-")...

EDIT:

t: copy "" append/dup t "." 10000 append t "-..---..--" rule: [while [not ["--"] skip] some "-"] print [delta-time [loop 1000 [parse t [rule] ]]]

=> ~ 15.4 sec on my phone

rule: [any ["--" break | skip] any "-"]

=> ~ 8.2 sec

rule: [to "--" some "-"] (@sqlab response)

=> ~ 0.3 sec

回答1:

What prevents you to use to as e.g.

rule: [to "--" some "-"  x:]