Skip to content

Instantly share code, notes, and snippets.

@WayneCui
Last active August 29, 2015 13:56
Show Gist options
  • Save WayneCui/9188031 to your computer and use it in GitHub Desktop.
Save WayneCui/9188031 to your computer and use it in GitHub Desktop.
Red Parse测试
Red []
str: "<Ids></Ids><Names></Names><Ids>99</Ids><Names>bar</Names>"
rule-1: [
some [
thru "<Ids>" insert "01" [ "</Ids>" | insert "," ]
thru "<Names>" insert "foo" [ "</Names>" | insert ","]
]
]
rule-2: [
some [
thru "<Ids>" insert "01" [ not "</Ids>" insert "," | skip ]
thru "<Names>" insert "foo" [ not "</Names>" insert "," | skip ]
]
]
parse str rule-1
;parse str rule-2
probe str
;output
;{<Ids>01</Ids><Names>foo</Names><Ids>01,99</Ids><Names>foo,bar</Names>}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment