Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dharmayejju/0cb77098fdd91b9a36989f25d0c70c77 to your computer and use it in GitHub Desktop.
Save dharmayejju/0cb77098fdd91b9a36989f25d0c70c77 to your computer and use it in GitHub Desktop.
//Masking inputs including char and digits
str = str.replace(/[a-zA-Z0-9-](?=[a-z0-9A-Z-]{4})/g, '*');
//Masking just digits
str = str.replace(/\d(?=\d{4})/g, "*");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment