Rebol PARSE rule to match thru first occurrence of at least 2 spaces

旧街凉风 提交于 2019-12-24 11:14:30

问题


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:]     


来源:https://stackoverflow.com/questions/54560201/rebol-parse-rule-to-match-thru-first-occurrence-of-at-least-2-spaces

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!