Regex 101: A Guide for No-code Builders

June 19, 2023

Regex. Sounds technical, doesn't it? It may seem daunting at first, but it's just a tool, a powerful one at that. It's time to demystify regex, or regular expressions, and showcase just how handy they can be for anyone, even non-programmers.

So, what is regex? It's a sequence of characters used to check, find, or manage text. For instance, if you want to ensure the email addresses entered in your app are in a valid format, regex is the tool for the job.

Understanding regex can be a game-changer for your no-code toolkit. It helps you ensure data consistency, streamline user interactions, and overall, boost your app's reliability.

This blog post will simplify regex for you. We'll provide you with useful examples and guide you on where to use them in your no-code tools. By the end of it, you'll see that you don't need to be a computer scientist to use regex effectively. Let's dive in!

Regex in No-Code Tools

Regular Expressions may have their roots in the world of coding, but they play a pivotal role in no-code platforms as well. No-code platforms empower us to create powerful applications, automate workflows, and manage data, all without writing a single line of traditional code. And regex is a valuable ally in this journey, enhancing the capabilities of these platforms.

Let's take form validation as an example. In no-code form builders like Noloco forms, regex can be used to verify if the input data matches the required format. Whether it's an email address, phone number, or custom ID, regex helps ensure that the data submitted is accurate and consistent. This not only saves time in data cleanup but also leads to more reliable outputs from your form.


Another exciting use of regex is in data extraction in platforms like Make (formerly Integromat) or Zapier. These platforms can pull data from one application and use it in another. Regex can help 'filter' and 'shape' this data during the extraction process. For instance, if you're extracting a list of email addresses from a document, a regex can help ensure only valid email addresses are captured, or you could extract the domain name from the email address.

In both scenarios, regex enhances the functionality of the no-code tools, allowing them to handle data with the same sophistication as a custom-built code solution. By mastering regex, you can wield these no-code tools with even more precision and effectiveness, achieving more with less manual intervention.

Regex Essentials

If you're entirely new to regular expressions (or 'regex'), you might be wondering what these strange combinations of letters, numbers, and symbols mean. Let's break it down in the simplest way possible.

Imagine regex as a filter for your data. You set up the filter based on what you're looking for, and it sifts through all the data, pulling out the pieces that match your criteria.

In regex, you create these filters using specific symbols and characters that have special meanings:

  • ^ means the start of a line.
  • $ means the end of a line.
  • . stands for any character.
  • * means the preceding element can be repeated zero or more times.
  • \d is a shortcut for any digit (0-9).
  • \w is a shortcut for any word character (a-z, A-Z, 0-9).
  • {n} specifies that the preceding element should be repeated 'n' times.

There are many more symbols and combinations, but these basics will help you make sense of the regex examples we're going to explore.

Now, regex can look a bit intimidating at first, much like seeing a foreign language. But remember, it's just a tool for filtering and finding data. The more you use it, the more familiar it becomes.

Common Regex Patterns

Here are 40 of the most common regex patterns that you could need divided into 3 categories:

  • Personalization
  • E-commerce
  • Social Media

Using regex for Personalization

Personalization is all about tailoring experiences to the individual user. Whether it's ensuring a user enters their name correctly, validating an email address, or formatting a phone number consistently, regex can help you deliver a personalized experience that feels professional and polished.

Full Name
This pattern validates a full name, which can be two words separated by a space.

Example: "John Doe"
Regex:

^[a-zA-Z]{1,}\s[a-zA-Z]{1,}$

           

First Name
This pattern checks if a first name is valid, assuming only letters are allowed.

Example: "John"
Regex:

^[a-zA-Z]{1,}$


Username
This pattern checks for a valid username that contains 4 to 15 alphanumeric characters.

Example: "JohnDoe123"
Regex:

^[a-zA-Z0-9_]{4,15}$


Email
This pattern checks for a valid email address.

Example: "john.doe@example.com"
Regex:

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$


Phone Number (US format)
This pattern checks for a valid U.S. phone number.

Example: "(123) 456-7890"
Regex:

^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$


Date (MM/DD/YYYY format)
This pattern checks for a valid date in the format MM/DD/YYYY.

Example: "01/01/2023"

Regex:

^(0[1-9]|1[0-2])/(0[1-9]|1\d|2\d|3[01])/([12]\d{3})$


Zip Code (US format)
This pattern checks for a valid U.S. zip code.

Example: "12345" or "12345-6789"
Regex:

^\d{5}(?:[-\s]\d{4})?$


URL
This pattern checks for a valid URL.

Example: "https://www.example.com"
Regex:

^(http|https)://[a-zA-Z0-9-\.]+\.[a-zA-Z]{2,}(/[a-zA-Z0-9]*)?$


IPv4 Address
This pattern checks for a valid IPv4 address.

Example: "192.168.0.1"
Regex:

^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$


Hexadecimal Color Code

This pattern checks for a valid hexadecimal color code.

Example: "#FFFFFF" or "#FFF"
Regex:

^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$

Using Regex in E-commerce

In the world of e-commerce, it's crucial to verify the accuracy of data input to maintain a smooth shopping experience. Regular expressions can help check the format and validity of important information such as credit card numbers, promotion codes, SKU numbers, and more. Let's take a look at ten e-commerce related regex examples:

Credit Card
This pattern checks for a valid credit card number with 13-16 digits.

Example: "1234567812345678"
Regex:

^\d{13,16}$


CVV
This pattern checks for a valid CVV number with 3-4 digits.

Example: "123"
Regex:

^\d{3,4}$


Promo Code
This pattern checks for a valid promo code, assuming it's a combination of 5 uppercase letters and numbers.

Example: "A1B2C"
Regex:

^[A-Z0-9]{5}$


SKU Number
This pattern checks for a valid SKU number, assuming it's a combination of 8 uppercase letters and numbers.

Example: "AB12CD34"

Regex:

^[A-Z0-9]{8}$

Quantity
This pattern checks for a valid quantity, assuming it's a number between 1 and 99.

Example: "15"
Regex:

^[1-9][0-9]?$

Price
This pattern checks for a valid price, assuming it's a number with up to two decimal places.

Example: "19.99"
Regex:

\d+(\.\d{1,2})?$

UPC Code
This pattern checks for a valid Universal Product Code, which should be exactly 12 digits.

Example: "123456789012"
Regex:

^\d{12}$

ISBN-13
This pattern checks for a valid 13-digit International Standard Book Number.

Example: "9781234567897"
Regex:

^(97(8|9))?\d{9}(\d|X)$

Address
This pattern checks for a basic address format, containing alphanumeric characters, spaces, and common punctuation.

Example: "123 Main St, Anytown, USA"
Regex:

^[a-zA-Z0-9\s,.]+$

Tracking Number (UPS)
This pattern checks for a valid UPS tracking number, which should be exactly 18 characters, starting with "1Z".

Example: "1Z12345E1512345676"
Regex:

^1Z[A-Z0-9]{16}$

Using Regex for Social Media Handles

Whether it's validating Twitter handles, YouTube video IDs, or LinkedIn URLs, regex can help ensure that user-entered social media information is in the correct format. Here are ten regex examples related to social media:

Twitter Handle
This pattern checks for a valid Twitter username. Twitter usernames can have 4 to 15 alphanumeric characters or underscores.

Example: "@username"
Regex:

^@?(\w){4,15}$


Facebook Username
This pattern checks for a valid Facebook username which is at least 5 characters long and can contain alphanumeric characters or periods.

Example: "username.1"
Regex:

^([a-z\d.]{5,})$


Instagram Handle
This pattern checks for a valid Instagram username. Instagram usernames can have 1 to 30 alphanumeric characters, periods, or underscores.

Example: "@username"
Regex:

^@?([a-zA-Z0-9_.]{1,30})$


LinkedIn URL
This pattern checks for a valid LinkedIn profile URL.

Example: "https://www.linkedin.com/in/username"
Regex:

^https://(www.)?linkedin.com/in/[a-zA-Z0-9_-]+$


YouTube Video ID
This pattern checks for a valid YouTube video ID which consists of 11 characters.

Example: "1a2B3C4d_5E"
Regex:

^[a-zA-Z0-9_-]{11}$

YouTube Channel ID

This pattern checks for a valid YouTube channel ID which starts with "UC" and followed by 22 alphanumeric characters, underscores, or hyphens.

Example: "UC1a2B3C4d_5E6F7G8H_9I"
Regex:

^UC[a-zA-Z0-9_-]{22}$


TikTok Username
This pattern checks for a valid TikTok username. TikTok usernames can have 2 to 24 alphanumeric characters, periods, or underscores.

Example: "@username"
Regex:

^@?[A-Za-z0-9_.]{2,24}$


Snapchat Username
This pattern checks for a valid Snapchat username which is 3-15 characters long and can contain alphanumeric characters.

Example: "username"
Regex:

^[A-Za-z0-9]{3,15}$


Reddit Username
This pattern checks for a valid Reddit username which is 3-20 characters long and can contain alphanumeric characters or underscores.

Example: "username_1"
Regex:

^[A-Za-z0-9_]{3,20}$


Pinterest Username
This pattern checks for a valid Pinterest username which is 3-30 characters long and can contain alphanumeric characters or underscores.

Example: "username_1"
Regex:

^[a-z0-9_]{3,30}$

Wrapping up

As we've seen, regular expressions, or 'regex', are a powerful tool for data validation, extraction, and manipulation. While it may seem a little intimidating at first, remember that with practice, understanding, and using regex will become second nature.

We've covered a broad spectrum of regex patterns useful in different contexts – from personalization to e-commerce, social media, and travel. With these patterns at your disposal, you're well-equipped to improve the accuracy and consistency of data across your no-code applications.

Remember, regex is flexible. It can be as simple or as complex as you need it to be, and there's always more to learn. If you want to delve deeper into regex, or try out your regex patterns, here are some additional resources:

  • Regular-Expressions.info: A comprehensive guide to understanding regex, perfect for beginners and experts alike.
  • Regex101: An interactive platform to test and debug your regex.
  • RegexOne: Offers interactive lessons to learn regex with exercises.
  • RegExr: Another excellent tool for testing and learning regex.