Rebol PARSE rule to match thru first occurrence of

2019-07-24 15:26发布

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条回答
趁早两清
2楼-- · 2019-07-24 16:06

What prevents you to use to as e.g.

rule: [to "--" some "-"  x:]     
查看更多
登录 后发表回答