Validation Rule REGEX Tester

Test a REGEX() pattern against real values, see which records would save, and copy the validation rule formula — escaped and ready to paste.

5 capital letters, 4 digits, 1 capital letter.

Would the record save?

  • ABCPE1234FSaves
  • abcpe1234fBlocked
  • ABCPE1234Blocked
  • AB1PE1234FBlocked

Validation rule formula

A validation rule shows its error when the formula is TRUE — so the formula says “doesn’t match”. Backslashes are doubled for you.

Runs in your browser — nothing you paste is sent to us or stored.

How to use it

  1. 1

    Pick or write a pattern

    Start from PAN, GSTIN, IFSC, PIN code, phone, email or postcode — or type your own. Write it with single backslashes, as in Java.

  2. 2

    Test real values

    Paste values from your data, one per line. Each shows whether the record would save or be blocked by the rule.

  3. 3

    Copy the formula

    Enter the field’s API name and copy the finished validation rule — backslashes doubled, blanks allowed if you want.

Questions

How does REGEX() work in a Salesforce validation rule?

REGEX(Field__c, "pattern") is TRUE when the whole value matches the pattern — not just part of it, so you don’t need ^ and $. A validation rule shows its error when its formula is TRUE, so the usual rule is NOT(REGEX(Field__c, "…")): “show the error when the value doesn’t match”.

Why do backslashes have to be doubled?

In a formula, the backslash is the escape character inside text strings. To pass \d to the regex engine you write "\\d" in the formula. This tool lets you type the pattern with single backslashes and doubles them in the formula it gives you. If you paste a pattern copied from a formula, it offers to fix it.

What happens when the field is blank?

REGEX() still runs on an empty value, and most patterns don’t match an empty string — so NOT(REGEX(…)) would make the field required. Tick “Allow the field to be left blank” to wrap the rule in AND(NOT(ISBLANK(Field__c)), …). Use the field’s Required setting if it must always be filled.

Is the result exactly what Salesforce will do?

Salesforce uses Java regular expressions; your browser uses JavaScript. They agree on almost everything validation rules use. Where Java behaves differently — possessive quantifiers, atomic groups, class intersection, \p{InBlock} — the tool tells you it can’t test that rather than guessing. (?i), \Q…\E and POSIX classes like \p{Alpha} are translated exactly.

Do the PAN and GSTIN patterns prove a number is real?

No. They check the format only. The last character of a GSTIN is a checksum, which a regular expression can’t verify, and no pattern can tell whether a PAN or IFSC was actually issued. Use them to catch typos at entry.

Is my data sent anywhere?

No. Patterns and values are tested in your browser; nothing is sent to Metrinfo or stored.

Further reading

Want to go beyond the tools?

Learn Salesforce administration — from beginner to certified — live classes with people who build on Salesforce every day.

See the learning path →