views:

512

answers:

2

I have a crystal report function which requires me to trim off characters which start with a "-" and delete the rest following the the "-" (dash).

for example.. I would have order number 00000112345-C43-PJ

how would I just trim off everything from the "-" and to the right and get the result 00000112345

I looked for a regex and substring but cr doesn't seem to have these functions available. thanks in advance

+2  A: 

Crystal might not have regex but it certainly has all the basic string functions

Something like this should do it for you (not tested):

Left({OrderNumber}, InStr({OrderNumber}, "-") - 1)
DJ
awesome that worked.. thanks
phill
A: 

This hasn't been a feature in Crystal reports for a while. I heard it might be a feature in the latest crystal reports (16?). Check out their website and give them a call, they shouldn't charge for a pre-sales question.

Another approach you could take to this is to manually process the value and validate it using the string and isvalue functions, etc. Messier, but it might be a backup option.

Jas Panesar