I have a requirement like this. My code generates random strings and it can be alpha, numeric and alphanumeric ones.
Lets say one of the numeric strings are "7882347812". I want to format this to 788.234.7812 based on a pattern like 3chars.3chars.4chars
If its an alphanumeric one like "h34jh8we7k". Then format this to h3/4jh8/we7k based on a pattern like 2chars/4chars/4chars.
If its an alpha one like "jkythjyv". Then format this to jky$thj$yv based on a pattern like 3chars$3chars$2chars.
In general, the generated strings can contain chars [a-zA-Z0-9]. This should be formatted as I mentioned above with any of the special characters. The input should be the string & the formatter and output should be the formatted string. Even a custom formatter is also fine.
I know how to write code for this. Is there any standard way of doing this in Java?