更改/部分无法按预期进行解析
根据 http://www.rebol.com/docs/core23/rebolcore- 15.html
您可以使用change/part来解析和替换,但这不适用于我只是尝试
<mytag > ... </mytag>
用“MyString”替换块
content: {<mytag id="a" 111111111111111>
</mytag>
aaaaaaaaaaaaaaa
aaaaaaaaaaaaaaa
<mytag id="b" 22222222222222222>
</mytag>
<mytag id="c" 3333333333333>
</mytag>
aaaaaaaaaaaaaaa
aaaaaaaaaaaaaaa
<mytag id="d" 444444444444444>
</mytag>
}
mytag: [ to {<mytag} start: (
)
thru {<mytag}
to {id="} thru {id="} copy ID to {"} thru {"}
to {</mytag>}
thru {</mytag>}
ending:
(change/part start "mystring" ending)
mark:
( write clipboard:// mark
input)
]
rule: [any mytag to end]
parse content rule
According to http://www.rebol.com/docs/core23/rebolcore-15.html
You can use change/part to parse and replace but that doesn't work well with this where I just try to replace the block
<mytag > ... </mytag>
by "MyString"
content: {<mytag id="a" 111111111111111>
</mytag>
aaaaaaaaaaaaaaa
aaaaaaaaaaaaaaa
<mytag id="b" 22222222222222222>
</mytag>
<mytag id="c" 3333333333333>
</mytag>
aaaaaaaaaaaaaaa
aaaaaaaaaaaaaaa
<mytag id="d" 444444444444444>
</mytag>
}
mytag: [ to {<mytag} start: (
)
thru {<mytag}
to {id="} thru {id="} copy ID to {"} thru {"}
to {</mytag>}
thru {</mytag>}
ending:
(change/part start "mystring" ending)
mark:
( write clipboard:// mark
input)
]
rule: [any mytag to end]
parse content rule
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您查看 http://en.wikibooks.org/ wiki/REBOL_Programming/Language_Features/Parse#Modifying_the_input_series
I point you to have a look at http://en.wikibooks.org/wiki/REBOL_Programming/Language_Features/Parse#Modifying_the_input_series
Ladislav 的建议是在不更改输入流的情况下解决这个问题,这可能会产生性能问题并且更难以调试。只需单独构建您的输出即可。例如
Ladislav's suggestion is to solve it without changing the input stream, which can have performance issues and is harder to debug. Just build up your output separately. e.g.