Page 1 of 1

Extracting sub string

Posted: Mon Jul 31, 2006 4:03 pm
by MikeN_(Guest)
Hello... I^m having a problem and I^m hoping you can help.____The character field stock->desc represents a sentence, and I want the second word of that sentence. I created this calculated field:____SUBSTR(stock->desc, STRSEARCH(" ",stock->desc,2)+1, STRSEARCH(" ",stock->desc,2) - STRSEARCH(" ",stock->desc,3)-1)____I want the string between the second and third space, but I always get null. Arggh! Why does this not work? Is there a better way? Thanks!____Miken

=> RE: Extracting sub string

Posted: Wed Aug 02, 2006 11:03 am
by kfleming
[updated:LAST EDITED ON Aug-02-06 AT 11:05 AM (EST)]R&R has a WORD function that does exactly what you want.__For example:__Word(stock->desc,2)____will return "blue" when stock->desc contains ^big blue marble"____Kathleen__R&R Support

==> RE: Extracting sub string

Posted: Fri Aug 04, 2006 2:54 pm
by MikeN_(Guest)
That *definitely* qualifies as a better way to do it, thanks!! Just out of curiousity, do you have any idea why the way I was trying didn^t work? Thanks____Miken

===> RE: Extracting sub string

Posted: Tue Aug 08, 2006 4:16 pm
by Alan_Klein
I think you have the math backwards. The third space will be at a greater number than the second space. When you subtract the location of the third space from that of the second space you will get a negative number.

====> RE: Extracting sub string

Posted: Wed Aug 09, 2006 1:47 pm
by MikeN_(Guest)
Yes, I see that now... thanks for the reply!____Miken