I want to apply a mask to my phone numbers, replacing some "*" characters.
The specification is as follows:
Phone Record : (123) 123-1234
Output : (1 **) *** - ** 34
I tried with this pattern: "\B\d(?=(?:\D*\d){2})"and replacing matches with "*"
But the final input is something like (123)465-7891 -> (1**)4**-7*91
Pretty similar to what I want, but with two extra matches. I was thinking of finding a way to use a zero match or once (??), but not sure how to do this.
source
share