Using regular expressions to mask/format strings
Posted on 2004-03-31
We're trying to fina a way to use regular expressions under vb.net to perform masking and formatting functions on data. For example, we have an object with an 'account number' property to it. This property has various metadata assigned to it--min value, max value, etc. What we would like to do is have a 'format' regexp as a string in the metadata that could be applied to the account number property to mask all but the last four digits. Example:
...apply the regexp here...
We know it will be strictly numeric; ie, no dashes or spaces, but we don't know how many digits the number might be. I've bounced this off a few knowledgable friends, but so far, nada. Ideally we'd like to be able to have formatting-type regeps or some sort of string that can be applied to data like this to mask it, format it, insert hyphens, whatever, but this first one is proving to be a pain in the neck.