Solved

"Cut out" a set substring in Crystal Reports

Posted on 2009-07-10
2
1,909 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now