1
......而且我碰壁了,我不明白爲什麼這不起作用(我需要能夠解析單個標籤版本(以/>結尾) )或2級標籤的版本(與終止)):我認爲這個解析會很簡單
Rebol[]
content: {<pre:myTag attr1="helloworld" attr2="hello"/>
<pre:myTag attr1="helloworld" attr2="hello">
</pre:myTag>
<pre:myTag attr3="helloworld" attr4="hello"/>
}
spacer: charset reduce [#" " newline]
letter: charset reduce ["ABCDEFGHIJKLMNOPQRSTUabcdefghijklmnopqrstuvwxyz1234567890="]
rule: [
any [
{<pre:myTag}
any [any letter {"} any letter {"}] mark:
(print {clipboard... after any letter {"} any letter {"}} write clipboard:// mark input)
any spacer mark: (print "clipboard..." write clipboard:// mark input) ["/>" | ">"
any spacer </pre:myTag>
]
any spacer
(insert mark { Visible="false"})
]
to end
]
parse content rule
write clipboard:// content
print "The end"
input
很多非常感謝克里斯爲這些詳細的答案我現在真的解析進展:) – 2010-03-18 07:58:11
但很明顯,不硬編碼像這樣的字符串長度!由於一個單詞的解析默認行爲是評估它,你可以使* replacement:{Visible =「false」} *,然後* replacement-length:length?替代*。在規則中使用替換和替換長度。當然,這一切都假設使用非DOM面向XML/HTML的解析器是一個好主意,我將重申它不是... :) – HostileFork 2010-03-18 19:41:21
+1爲人們做Rebol Q&A之外的想法AltME和R3聊天。如果社區中的其他人可以談論加入文明的其他部分,它可能不會像這樣一種死去的語言...讓我們得到更多的東西。 – HostileFork 2010-03-18 19:42:54