Print Page | Close Window

Remove after 2nd space in a text string

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=17431
Printed Date: 05 May 2024 at 9:04am


Topic: Remove after 2nd space in a text string
Posted By: patgio
Subject: Remove after 2nd space in a text string
Date Posted: 28 Aug 2012 at 3:50am
Hi,
I'm using CRXI

I have a field which contains text such as:
"Item one has this description"
"The second item has different text"
"And so does the third"
"And on and on"

I would like my report to remove all text after the 2nd space so that the report would have:
Item one
The second
And so
And on

In the report, I'm using format field; display string with the following formula:

extractstring({vRptScheduledExams.ExamDesc},"",mid({vRptScheduledExams.ExamDesc},
instr({vRptScheduledExams.ExamDesc}," ")+0))

This removes all text after the first " " (space).
It returns only:
Item
The
And
And
How do I advance the formula to remove after the second space?
Thanks for your help.

Patrick





Replies:
Posted By: z9962
Date Posted: 29 Aug 2012 at 12:01am
try this
 
left({vRptScheduledExams.ExamDesc},instr((instr({vRptScheduledExams.ExamDesc}," ")+1),{vRptScheduledExams.ExamDesc}," ")-1)
 


Posted By: patgio
Date Posted: 29 Aug 2012 at 1:42am
wow.. that is amazing.
Thank you very much.
It works perfectly.



Print Page | Close Window