Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal reports Description contains bracket

Status
Not open for further replies.

Kevin Mizzi

Technical User
Jul 4, 2023
6
0
0
MT
hello,

i need to show a part of a description, if the description is Testing (6) (with bracket) i need to show only the 6 in the bracket. any idea please?

 
Hi dgillz

thanks for your reply.

what i need is if a description is Testing (6) i need to remove the description Testing and Showing only the (6) and if possible without brackets. so the result should be 6 only.
 
Will the data always be exactly what you put above, or is that just an example? The following will ignore whatever string precedes the opening bracket, and return everything from that point but excluding the brackets themselves.

Code:
REPLACE(REPLACE(MID({Table.Field}, INSTR({Table.Field}, '(')), '(', ''), ')', '')

But if there are other patterns to the data it will not work. If the above code does not work you will need to explain all possible patterns.

Hope this helps.

Cheers
Pete.

 
hi Pete

thanks for your reply

i forgot to mentioned that the description is Testing (6) 451221 and i need to show only the 6 which are in the brackets - so i need to remove Testing () 451221
 
The following code will return everything between the brackets.

Code:
Local numbervar start := INSTR({Table.Field}, '(');
Local numbervar end   := INSTR({Table.Field}, ')');
MID({Table.Field}, start + 1, (end - start - 1))

Cheers,
Pete
 
hi Pete,

if the description doesn't contains the ( Bracket in the description can i use "else" or "then" to showing the word "to fill" ? because i'm getting an error where the bracket is not available in the description.

thanks

 
This is why you need to understand your data, and provide all the details at the outset.

Code:
Local numbervar start := INSTR({Table.Field}, '(');
Local numbervar end   := INSTR({Table.Field}, ')');

IF      start > 0
THEN    MID({Table.Field}, start + 1, (end - start - 1))
ELSE    {Table.Field}

This will return the original contents of {Table.Field} when no opening bracket exists, and assumes there will always be a closing bracket whenever an opening bracket exists. Depending on what you want to happen when there is no '(' you might need to change the ELSE result.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top