Hi TB,
have a look at this one ...
REBOL []
test-cases: [
"I have a fluffy kitty and a black lab" TRUE
"I have a fluffy kitty and a orange tabby" FALSE
"Where is my mangy mutt?" False
"Where can I buy a book on programming REBOL?" False
]
cat: [thru "orange" "tabby" | thru "fluffy" "kitty" ]
dog: [thru "mangy" "mutt" | thru "black" "lab" ]
rule: [ cat dog | dog cat ] ; to be sure to catch them either way
foreach [str val] test-cases [
prin [ str "(" val ") -> "]
print parse str rule
]
comment {
My first idea for 'rule was
rule: [ some [ cat (cat-found: true) | dog (dog-found: true) ]
Problems:
- without them xxx-found: true you couldn't be
sure, to not catch cat twice (sentence 2).
- a sentence with 'dog and 'cat in this order
"I have a black lab and a fluffy kitty."
would first find the kitty, and thus read over
your dog. I _think_ there was a solution to
this ...
Note: Parse capabilities have greatly improved in /View,
and will be part of the next /Core release, too.
}
halt
I hope this helps
Ingo
-- _ . _
ingo@)|_ /| _| _ <We ARE all ONE www._|_o _ _ ._ _
www./_|_) |o(_|(/_ We ARE all FREE> ingo@| |(_|o(_)| (_|
http://www.2b1.de/Rebol/ ._| ._|