Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Linux / UNIX and the fly likes regular expression Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Reply Bookmark "regular expression" Watch "regular expression" New topic
Author

regular expression

Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1854
Hi,
We need to mask credit card numbers.Masking all but last 4 digits. I am trying to use SED. As credit card number length varies from 12 digits to 19,I am trying to write regular expression.Following code will receive the String. If it contains String of the form "CARD_NUMBER=3737291039299199", it will mask first 12 digits.
Problem is how to write regular expression for credit card-12 to 19 digits long? If I write another expression for 12 digits, it doesn't work.that means for 12 digit credit card- first 8 digits should be masked. for 15 digit credit card, first 11 digits should be masked.


MH
Josh Stephens
Greenhorn

Joined: Feb 16, 2010
Posts: 8
What if you did a split string with the = sign being the identifier. Then find the length of the index of your array which should be the card number.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923



For lengths of 3+4=7 to 5+4=9. You'll loose the information of the CN-length.


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: regular expression
 
Similar Threads
Masking Password in log file
sed regular expression
how to replace a string on a line irrespective of the position
Find 16digit number and mask particular position using regular expression
mask cc number in log files from a string in the log file