Parsing query. Better example.
[1/3] from: tbrownell::l3technology::com at: 27-Feb-2003 16:00
This is a better example...
str:
Some text... Section 1
abc1, blah blah
=> abc2, blah, blah blah
=> abc3, blah blah, blah
=> abc4, blah, blah
Section 2
abc5, blah blah, blah
=> abc6, blah blah, blah
=> abc7, blah, blah
Where I end up with...
n: ["abc1" "abc2" "abc3" "abc4" "abc5" "abc6” “abc7”]
A wee far cry from the last example.
TB
[2/3] from: brett:codeconscious at: 28-Feb-2003 11:31
Doens't look like a valid string Terry (ie is the "s part of the text you
are parsing?).
There could be a few ways of approaching it, once the
assumptions/constraints are known.
Here is one example (which assumes that "abc" is followed by a single
numerical digit):
result: copy []
parse str [any [ copy item ["abc" skip] (append result item) | skip ] ]
?? result
You might be interested in this:
http://www.codeconscious.com/rebol/parse-tutorial.html
Brett.
----- Original Message -----
From: "Terry Brownell" <[tbrownell--L3TECHNOLOGY--COM]>
To: <[rebol-list--rebol--com]>
Sent: Friday, February 28, 2003 11:00 AM
Subject: [REBOL] Re: Parsing query. Better example.
This is a better example...
str:
Some text... Section 1
abc1, blah blah
=> abc2, blah, blah blah
=> abc3, blah blah, blah
=> abc4, blah, blah
Section 2
abc5, blah blah, blah
=> abc6, blah blah, blah
=> abc7, blah, blah
Where I end up with...
n: ["abc1" "abc2" "abc3" "abc4" "abc5" "abc6" "abc7"]
A wee far cry from the last example.
TB
[3/3] from: tomc:darkwing:uoregon at: 27-Feb-2003 21:31
str: {
Some text... Section 1
abc1, blah blah
=> abc2, blah, blah blah
=> abc3, blah blah, blah
=> abc4, blah, blah
Section 2
abc5, blah blah, blah
=> abc6, blah blah, blah
=> abc7, blah, blah
}
result: copy []
valid: complement charset {, #"^/"}
valids: [some valid]
section: [
thru "Section" number!
thru newline
(rslt: copy [])
some [ opt ["=> "]
copy s valids (append rslt s)
thru newline
]
(append/only result rslt)
opt newline
]
parse str [some section]
== true
result
== [["abc1" "abc2" "abc3" "abc4"] ["abc5" "abc6" "abc7"]]
close enough?
On Thu, 27 Feb 2003, Terry Brownell wrote: