Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Removing brackets Post Reply Post New Topic
Author Message
chrispfeiffer
Newbie
Newbie


Joined: 24 Jun 2009
Location: United Kingdom
Online Status: Offline
Posts: 9
Quote chrispfeiffer Replybullet Topic: Removing brackets
    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

replace({Field.String},"(*)","")

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

Any ideas please?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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}
IP IP Logged
chrispfeiffer
Newbie
Newbie


Joined: 24 Jun 2009
Location: United Kingdom
Online Status: Offline
Posts: 9
Quote chrispfeiffer Replybullet Posted: 15 Nov 2019 at 5:56am
Thank you - that works a treat!
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.