[REBOL] Re: Problem with parse
From: pwawood:gmai:l at: 30-Oct-2008 22:10
Hello Peter!
I don't have the answer to why you're third case doesn't work but have
this parse-it-yourself solution that seems to give the result you are
seeking. I'm sure there are many better ways to do what you want and
hopefully others will chip in with them.
>> parse-rule: [
[ 2 [copy data to "|" skip (insert/only tail parse-output data)]
[ copy data to end (insert/only tail parse-output data)
[ ]
You will need to use it like this:
>> parse-output: copy []
== []
>> line: {2008-10-30|This is OK|http://www.example.com}
== "2008-10-30|This is OK|http://www.example.com"
>> parse/all line parse-rule
== true
>> head parse-output
== ["2008-10-30" "This is OK" "http://www.example.com"]
>> parse-output: copy []
== []
>> line2: {2008-10-30|This "is" OK|http://www.example.com}
== {2008-10-30|This "is" OK|http://www.example.com}
>> parse/all line2 parse-rule
== true
>> head parse-output
== ["2008-10-30" {This "is" OK} "http://www.example.com"]
>> parse-output: copy []
== []
>> line3: {2008-10-30|"This is" NOK|http://www.example.com}
== {2008-10-30|"This is" NOK|http://www.example.com}
>> parse/all line3 parse-rule
== true
>> head parse-output
== ["2008-10-30" {"This is" NOK} "http://www.example.com"]
Regards
Peter
On 30 Oct 2008, at 20:52, Peter Carlsson wrote: