Solved

"Cut out" a set substring in Crystal Reports

Posted on 2009-07-10
2
1,933 Views
Last Modified: 2012-05-07
I have a comment field from the database and I want to "cut out" a portion of the comment and then display the remaining string in a Crystal Report formula field.  The substring that I want to eliminate is always the same, but it may not be in the same place.  It may also not be in the comment at all.  If it appeared in the comment, it would only appear once. I could also use some help on cutting out more than one space between the remaining text strings.  For example:

DATABASE COMMENT STRING                                 WANT TO DISPLAY
'This is a comment. Other text. More text'                  'Other text. More text'
'More text. This is a comment.    Other text'               'More text. Other text'
'Other text  This is a comment.'                                  'Other text'
'More text... and more.This is a comment. More'        'More text... and more. More'
'A different comment'                                                 'A different comment'

I've already created a formula, but need the exact code.  This is pseudocode:
if string contains 'This is a comment.'
   remove 'This is a comment.' and any spaces inbetween and then display comment
else
   display comment

0
Comment
Question by:bshelby777
2 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 24829296
replace(replace({table.field}, "This is a comment.",""),"  "," ")

The outer replace() replaces two spaces with one.
0
 

Author Closing Comment

by:bshelby777
ID: 31602372
Worked like a charm.  Thanks so much for your quick and accurate response.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Crystal Reports Sum only working when drilling down 20 60
Business Object Server 2 30
Crystal Reports 12 41
How to modify the SQL query in Crystal 2016 1 28
Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question