I'm using snap in chat and we need to mask credit card numbers for agents inside salesforce. For this reason I am trying to use sensitive data rules.

Can any one please tell me how to use regular expression for sensitive data rules in salesforce for VISA, Master and Amex and discover.

I tried but it is not working at all in the snap in chat.

I am using the below Regexpression :

VISA - /^(?:4[0-9]{12}(?:[0-9]{3})?)$/

enter image description here

1 Answer 1


I had same issue and logged case with Salesforce and they responded following explanation and solution.

Note below example is for SSN Number Regular expression not Credit Card.

" This is the result of a JavaScript incompatibility with the negative lookbehind used in the following regex formula:


At the beginning there is a negative lookbehind (?>!), which is a relatively new function introduced with the ECMA2018 JavaScript standard.

As of now Chrome is the only browser that supports this standard. It may be possible to resolve this issue by using a negative lookahead instead, but it depends on what the end goal is for the pattern that needs to be detected.

Negative Lookbehind (?>!): https://regex101.com/r/twxLNc/1

Negative Lookahead (?!): https://regex101.com/r/ft2ifO/1

Both of the examples above will work in Chrome, but the negative lookbehind example will not work in Safari or Firefox, the regex doesn't work in Safari or Firefox because the JavaScript Engines in these browsers do not support negative lookbehind. "

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .