Start a new topic

Useful regular expressions

E-mail

\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b


Date of Birth

\b\d{2}/\d{2}/\d{4}\b


National Insurance Number

\b[A-Z]{2}\s\d{2}\s\d{2}\s\d{2}\s[A-Z]\b


Passport Numbers

\b\d{9}\b


Car Registrations

\b\p{Lu}+\s\p{Lu}+\s\d+\b|\b\p{Lu}+\s\d+\s\p{Lu}+\b|\b\p{Lu}+\d+\s\p{Lu}+\b|\b\p{Lu}+\s\d+\p{Lu}+\b


Telephone Numbers

\b\d{4}\s\d+-\d+\b


Social Security Numbers

\b(?!000)(?!666)[0-8][0-9]{2}[- ](?!00)[0-9]{2}[- ](?!0000)[0-9]{4}\b


IP6 Address

(?<![:.\w])(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}(?![:.\w])


PCI

\b(?:\d[ -]*?){13,16}\b

1 Comment

I forgot to precede the pipe:


E-mail

|\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b


Date of Birth

|\b\d{2}/\d{2}/\d{4}\b


National Insurance Number

|\b[A-Z]{2}\s\d{2}\s\d{2}\s\d{2}\s[A-Z]\b


Passport Numbers

|\b\d{9}\b


Car Registrations

|\b\p{Lu}+\s\p{Lu}+\s\d+\b|\b\p{Lu}+\s\d+\s\p{Lu}+\b|\b\p{Lu}+\d+\s\p{Lu}+\b|\b\p{Lu}+\s\d+\p{Lu}+\b


Telephone Numbers

|\b\d{4}\s\d+-\d+\b


Social Security Numbers

|\b(?!000)(?!666)[0-8][0-9]{2}[- ](?!00)[0-9]{2}[- ](?!0000)[0-9]{4}\b


IP6 Address

|(?<![:.\w])(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}(?![:.\w])


PCI

|\b(?:\d[ -]*?){13,16}\b

txt
(557 Bytes)
Login to post a comment