java - Regex to mask a PhoneNumber -


i need mask phonenumber result is

 (***)-(***)-xxxx 

xxxx being last 4 digits of number.

right code

 string mask = phonenumber.replaceall("(?<=.).(?=[^-()]*?.-)", "*"); 

result (***)***x-xxxx.

  string mask1 = phonenumber.replaceall("(?:[^()-])", "*"); 

result

 (***)-***-****  

i not able know mistake making.

$string =~ s{([0-9]{3})([0-9]{3})([0-9]{4})}{($1)-($2)-$3}g; 

try replace.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -