Solved

"Cut out" a set substring in Crystal Reports

Posted on 2009-07-10
2
1,944 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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 Repeat Report Footer X amount of times 6 58
Conditional Text in Crystal 4 69
Crystal Reports 13 5 98
Excel datasource returning records twice?? 1 25
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…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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