tony — 27-Jan-2012/20:25:07-8:00
I've spent all day trying to extract one word from a string and am totally frustrated. Here is a string -
str: "John and Terry went home"
I do not want anything after the part I want to find. Find the word "went".
find str "went"
"went home" is returned. How do I get only the word "went"?
tony — 28-Jan-2012/0:25:39-8:00
case [] function works good!
Is there anything better??
DocKimbel — 28-Jan-2012/3:24:19-8:00
There are several ways to achieve it depending on your usage context:
1) parse str [to "went" copy w to " "]
?? w
2) w: form fourth load str
?? w
3) w: fourth parse str none
?? w
4) pos: find str "went"
w: copy/part pos find pos " "
?? w
Hope this helps.
tony — 28-Jan-2012/15:36:28-8:00
Thanks Doc! I decided to use "either" function instead. I just needed to test for a word, not retrieve it this time.