Masking numbers

Hi there,

I need some assistance please in masking some numbers.

Below are samples of the number formats that I am working with.

11111-0-1111111-1111
11111-0-111111-1111
11111-0-11111-1111

Let’s call the field costing.costing_number.

Essentially, I need to:

• Display the first 5 digits (ie. Everything to the left of the first ‘-‘)
• Display 7 asterisks in the middle
• Display the last 4 digits (ie. Everything to the right of the final ‘-‘)

I would like this masking to apply irrespective of the length of the original field

So…I envisage my masking looking like this (using the same numbers as above):

11111*******1111

HOWEVER, I need to be prepared for exceptions and dirty data.

So, if my data is not in any of the formats above (eg. If the data already reads something like 1111*******111), then I need to simply display the field (costing.costing_number).

Is there anyone that could please assist me with this?

Many thanks in advance!

Cheers,

Corinne


creeno (BOB member since 2011-04-05)

Using the Left() and Right() functions, this is not that difficult. You would do something like this (assuming that you ALWAYS want exactly 7 asterisks):

Left({MyTable.MyField}, 4) + ‘*******’ + right({MyTable.MyField}, 4)

If you have a variable number of asterisks, you could do something like this:

StringVar stars = ‘********************’;
Left({MyTable.MyField}, 4) + Left(start, Length({MyTable.MyField}) - 8 ) + Right({MyTable.MyField, 4)

-Dell


hilfy :us: (BOB member since 2007-04-16)

Perfect. Thank you so much for your response!


creeno (BOB member since 2011-04-05)