I am reading a string ID value from a table. When the ID was input by the user, it was done with an input mask that the user defined, so the mask could have been something like 000-00-0000
, ##-######
, AA-9999999
, etc. The mask will vary by user, and so must be evaluated at runtime.
Given that only the alphanumeric text is stored in the table, what is the best way of generating a new string with that mask applied?
For example:
Table value = "123456789"
If user has defined mask of 000-00-0000
, I want to get string 123-45-6789
.
If user has defined mask of AA-9999999
, I want to get string 12-3456789
.
If user has defined mask of FR999_999999
, I want to get string FR123_456789
.