Extract a word from a string - not easy for me!
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"?
posted by: tony 27-Jan-2012/20:25:07-8:00
case  function works good!
Is there anything better??
posted by: tony 28-Jan-2012/0:25:39-8:00
There are several ways to achieve it depending on your usage context:
1) parse str [to "went" copy w to " "]
2) w: form fourth load str
3) w: fourth parse str none
4) pos: find str "went"
w: copy/part pos find pos " "
Hope this helps.
posted by: DocKimbel 28-Jan-2012/3:24:19-8:00
Thanks Doc! I decided to use "either" function instead. I just needed to test for a word, not retrieve it this time.
posted by: tony 28-Jan-2012/15:36:28-8:00