Reputation: 86757
I'd like to mask out sensitive credit card details. Therefore trying to create matcher that finds:
<CreditCard Number="123456789" CVC="111" />
Then I want to replace the numbers/values that are found.
So far I have: (CreditCard.*CVC=").*?"
. This would match the string CreditCard Number="123456789" CVC="111"
.
What do I have to change so that only the numbers inside either CVC or Number double quotes are matched?
Upvotes: 0
Views: 85
Reputation:
Lookahead and Lookbehind are the magic words. Here is an example to match your CVC number...
(?<=CVC=\")\d+(?=\")
Upvotes: 2