Link to home
Start Free TrialLog in
Avatar of bshelby777
bshelby777Flag for United States of America

asked on

"Cut out" a set substring in Crystal Reports

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

ASKER CERTIFIED SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bshelby777

ASKER

Worked like a charm.  Thanks so much for your quick and accurate response.