Print Page | Close Window

Removing brackets

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2016
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
Printed Date: 10 Aug 2020 at 8:33am

Topic: Removing brackets
Posted By: chrispfeiffer
Subject: Removing brackets
Date Posted: 14 Nov 2019 at 9:52pm
Hello - I need to remove parts of text from a string (I'm using Crystal Reports X) where the part that needs removing is contained within brackets AND I also need to remove the brackets. As an example:

The white rabbit (white rabbit)

So in the example above I need to remove (white rabbit)

I have tried


but that has no effect at all i.e. nothing changes.

Any ideas please?

Posted By: DBlank
Date Posted: 15 Nov 2019 at 2:36am
first you have to verify that the only time () is used in the string is where you want to remove the content. If the part you want to remove is always at the end of the string you can
use instr() to find the placement of the "(" and then left() on that field with the result something like this

if instr({Field.string},"(")>0 then
rtrim(left({Field.string},instr({Field.string},"(")-1)) else {Field.string}

Posted By: chrispfeiffer
Date Posted: 15 Nov 2019 at 5:56am
Thank you - that works a treat!

Print Page | Close Window