#K74367. Mask Credit Card Numbers
Mask Credit Card Numbers
Mask Credit Card Numbers
In this problem, you are given a string which may contain one or more credit card numbers. A valid credit card number is defined as a sequence of exactly 16 consecutive digits. Your task is to replace the first 12 digits of each valid credit card number with asterisks ('*') while keeping the last 4 digits unchanged. This masking should only occur when the 16-digit sequence is properly delimited by non-digit characters (i.e. word boundaries).
The masking rule can be expressed as:
$$\text{Masked}(\text{number}) = \underbrace{************}_{12\text{ asterisks}}\text{last4}\ $$Input is provided via standard input and output should be written to standard output.
inputFormat
A single string read from standard input. The input string may span multiple lines and can contain valid credit card numbers (exactly 16 consecutive digits) along with other text.
outputFormat
Output the transformed string to standard output. Every valid credit card number in the input should have its first 12 digits replaced by asterisks, with the last 4 digits preserved, while all other parts of the string remain unchanged.## sample
My credit card number is 1234567812345678.
My credit card number is ************5678.
</p>