Extracting sub string
-
- Posts: 37
- Joined: Tue Oct 10, 2017 12:44 pm
Extracting sub string
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
[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
-
- Posts: 37
- Joined: Tue Oct 10, 2017 12:44 pm
==> RE: Extracting sub string
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
-
- Posts: 68
- Joined: Tue Oct 10, 2017 12:44 pm
===> RE: Extracting sub string
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.
-
- Posts: 37
- Joined: Tue Oct 10, 2017 12:44 pm
====> RE: Extracting sub string
Yes, I see that now... thanks for the reply!____Miken