Useful REGEX sniplets

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Search 3B Knowledge Base

You are here:
< Back

What is this article about?

3B Forms support custom field validation through the use of Javascript RegExt. This is a simple piece of code which allows you to control the format of the data inputted on your forms. Below, you can find a list of useful/most used RegEx snipplets that you can just add to your forms.

How do I add Custom RegExt to fields?

Just jump over to edit any valid field (Text Fields, Date/Time Fields) from the Form Builder. In the field settings pop-up, right at the bottom, you will see a panel such as this one:

The last option in this panel is called Custom Regular Expression Formula which is where you need to input your RegEx formulas



1. US Social Security Number

  1. The Area Number (A) – This is a three digit number that was used to assign a Social Security number based on geographic location. This could either be the specific office code that the card itself was issued from or based on the zip code that the applicant lived in.
  2. The Group Number (G) – This is a two digit number that ranges from 00-99 and used a specific set of rules to build the sequence from the first value to the last within the group to avoid consecutive values being used.
  3. The Serial Number (S) – This is a straight-forward numeric sequence that is output consecutively from 0000-9999.


2. UK National Insurance Number

AB 12 34 56 A
AB 123456 A
AB 123 456 A
AB 1 2345 6 A
AB 12 34 56 A


3. US Post Code/ZIP Format

  1. 12345
  2. 12345-6789
  3. 12345 1234


4. UK Post Code Format

([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z]))))\s?[0-9][A-Za-z]{2})
  1. CW3 9SS
  2. SE5 0EG
  3. SE50EG
  4. se5 0eg
  5. WC2H 7LT


5. Simple Password Validation


Matching  6 to 18 letters, numbers, underscores, or hyphens – no special charecters.


6. Matching an Email

We begin by telling the parser to find the beginning of the string (^). Inside the first group, we match one or more lowercase letters, numbers, underscores, dots, or hyphens. I have escaped the dot because a non-escaped dot means any character. Directly after that, there must be an at sign. Next is the domain name which must be: one or more lowercase letters, numbers, underscores, dots, or hyphens. Then another (escaped) dot, with the extension being two to six letters or dots. I have 2 to 6 because of the country specific TLD’s ( or Finally, we want the end of the string ($).


7. Matching a URL

/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
This regex is almost like taking the ending part of the above regex, slapping it between “http://” and some file structure at the end. It sounds a lot simpler than it really is. To start off, we search for the beginning of the line with the caret.

The first capturing group is all option. It allows the URL to begin with “http://”, “https://”, or neither of them. I have a question mark after the s to allow URL’s that have http or https. In order to make this entire group optional, I just added a question mark to the end of it.

Next is the domain name: one or more numbers, letters, dots, or hypens followed by another dot then two to six letters or dots. The following section is the optional files and directories. Inside the group, we want to match any number of forward slashes, letters, numbers, underscores, spaces, dots, or hyphens. Then we say that this group can be matched as many times as we want. Pretty much this allows multiple directories to be matched along with a file at the end. I have used the star instead of the question mark because the star says zero or more, not zero or one. If a question mark was to be used there, only one file/directory would be able to be matched.

Then a trailing slash is matched, but it can be optional. Finally we end with the end of the line.





Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

3B Initiative

Jonathan B – 5 Stars

Get this and simplify your processes Thank you for your review, Jonathan, a happy little acacia tree is planted in your name! The exact coordinates

3B Initiative

Andy K – 5 Stars

Makes forms easy Thank you for your review, Andy, a happy little acacia tree is planted in your name! The exact coordinates of the tree

3B Initiative

Matthew W – 5 Stars

Best Free Forms Product on the AppExchange Thank you for your review, Matthew, a happy little acacia tree is planted in your name! The exact

Innovate, improve, empower. We believe engaged and happy customers make great partners, and see continuous feedback and collaboration as key levers in our shared drive for success. You need a small customisation to fit that nonconforming process step you have? We are more than happy to offer it free of charge. You have a recommendation for improvement/feature implementation? We are happy to listen, and will issue you with a special certificate to credit you for an idea that goes into the product.

As (we hope) you probably guessed yourself already – we want to be the single most flexible and customer-friendly forms solution on the market.