Joined: 24 Jun 2009
Location: United Kingdom
Online Status: Offline
Posts: 9
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.
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
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}
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