Extracting sub string

Meeting place for R&R customers and clients to share tips and ideas. Post your questions, messages or problems here.
Post Reply
MikeN_(Guest)
Posts: 37
Joined: Tue Oct 10, 2017 12:44 pm

Extracting sub string

Post by MikeN_(Guest) » Mon Jul 31, 2006 4:03 pm

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

kfleming
Posts: 5795
Joined: Tue Oct 10, 2017 12:44 pm

=> RE: Extracting sub string

Post by kfleming » Wed Aug 02, 2006 11:03 am

[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

MikeN_(Guest)
Posts: 37
Joined: Tue Oct 10, 2017 12:44 pm

==> RE: Extracting sub string

Post by MikeN_(Guest) » Fri Aug 04, 2006 2:54 pm

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

Alan_Klein
Posts: 68
Joined: Tue Oct 10, 2017 12:44 pm

===> RE: Extracting sub string

Post by Alan_Klein » Tue Aug 08, 2006 4:16 pm

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.

MikeN_(Guest)
Posts: 37
Joined: Tue Oct 10, 2017 12:44 pm

====> RE: Extracting sub string

Post by MikeN_(Guest) » Wed Aug 09, 2006 1:47 pm

Yes, I see that now... thanks for the reply!____Miken

Post Reply