5

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 right of the "-" get the result as 00000112345?

I looked for a regex and substring but crystal doesn't seem to have these functions available.

Tom Wright
  • 11,278
  • 15
  • 74
  • 148
phill
  • 13,434
  • 38
  • 105
  • 141

3 Answers3

4

I've recently added a regex library here:- https://sourceforge.net/projects/cruflregex/files/

It's a bit minimal, but might be of use to someone.

  • +1 Nice. You may want to post the source file in SourceForge instead of an archive of the source. – craig Dec 23 '11 at 17:04
  • @craig Good point, thanks for the feedback. You see lots of downloads of these things but no-one ever says anything. It's nice to hear that someone has looked at it. –  Jan 12 '12 at 09:41
  • Have you tested this with Crystal Reports 12? Is the .PDB file required for the .DLL to function? – craig Jan 12 '12 at 18:50
  • @craig PDB is only for debugging symbols so you don't need it. I haven't tested with CR 12 as I don't have it. –  Jan 13 '12 at 11:17
  • 1
    For Crystal Reports 2008 (v 12.x), the DLL (u25regex.dll) needs to be deployed in the `C:\Program Files\Business Objects\BusinessObjects Enterprise 12.0\win32_x86` directory. – craig Aug 01 '12 at 12:02
  • @user159335, while `RxMatch( "foo 08/01/2012 bar", "[0-9]{2}/[0-9]{2}/[0-9]{4}" )` returns True, `RxGetMatches( "foo 08/01/2012 bar", "[0-9]{2}/[0-9]{2}/[0-9]{4}" )[1]` generates an array-bounds error. Ubound( `RxGetMatches( "foo 08/01/2012 bar", "[0-9]{2}/[0-9]{2}/[0-9]{4}" )[1]` ) equals 0, when it should equal 1. Thoughts? – craig Aug 01 '12 at 12:23
2

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.
  • 16,045
  • 3
  • 42
  • 46
0

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
  • 6,597
  • 3
  • 36
  • 47