Search This Blog

Tuesday, June 16, 2015

Regex

Masking credit card number:
In credit card there are totally 16 digits, first 12 is masked as * and last 4 has to be displayed 
Pattern:
/\d{12}(\d{4})/
\d-Digit
X{n}-Matches any string that contains a sequence of X n's
Example:
 var strMaskedName=strName.replace(/\d{12}(\d{4})/, "**** **** **** $1");

Masked all string and digit in the input field.
Pattern:
/.+/

Example:
var Name="Alagu@123":
var strname=Name.replace(/.+/, "************");

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.