Skip to main content

Atom Tips: Regex or Regular Expressions

🧩 What are Regular Expressions (Regex)?

Regular Expressions (or Regex) are sequences of characters that form a search pattern. In Atom, they are used primarily within bot flows to validate that information entered by a customer has the correct format (for example, ensuring that text is really an email address or that an identity number has the exact length).


Learning to create them will give you complete control over the responses that your bot accepts as valid.


🛠️ Basic elements to create your own Regex


Creating a Regex is like putting together a puzzle using special symbols (metacharacters). Here are the most important ones to start building your own rules:


1. Anchors (Position)


They help you define where the text should start or end.

  • ^ (Caret): Indicates the beginning of the text. Example: ^Hello (the message must necessarily start with "Hello").

  • $ (Dollar sign): Indicates the end of the text. Example: end$ (the message must end exactly with "end").

2. Character Classes (What to search for)


Shortcuts for grouping types of letters or numbers.

  • \d : Matches any digit (0 to 9).

  • \w : Matches any alphanumeric character (letters and numbers).

  • \s : Matches any whitespace.

  • [a-z] : Matches any lowercase letter in that range.

  • . (Period): Matches any character (except line breaks).

3. Quantifiers (How many times)


They tell the system how many times the previous element can repeat.

  • * (Asterisk): The element can appear zero or more times.

  • + (Plus): The element must appear one or more times.

  • ? (Question mark): The element is optional (zero or one time).

  • {n} : Exactly n times. Example: \d{4} (exactly 4 numbers).

  • {n,m} : Between n and m times.

4. Logical operators

  • | (Pipe / Vertical bar): Works as a logical "OR". Example: (yes|sure|ok) will accept any of those three words.


📝 Practical examples to use in Atom


Here's how these symbols look when combined for real use cases in your FlowBuilder:
Example 1: Validate an exact document number (ID/License)

  • Regex: ^\d{8}$

  • Explanation: The text must start (^) and end ($) with exactly eight numbers (\d{8}). If the customer types letters or 9 numbers, the bot will reject it.

Example 2: Capture variations of affirmation

  • Regex: ^(yes|yeah|sure|of course|ok)$

  • Explanation: Useful in an "Evaluate Response" component. The bot will understand that the customer said "yes", regardless of which of those options they wrote, as long as it's exactly that word.

Example 3: Validate an email address format

  • Regex: ^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$

  • Explanation: Ensures that there is alphanumeric text at the beginning, followed by an "@", then the domain (like gmail or hotmail), a period, and a valid ending (like .com or .net).


💡 Atom's Golden Tip


Before saving your Regex on the platform, we recommend testing it on free sites like Regex101.com. There you can write your formula and put test texts to make sure the pattern works exactly as you imagined before it interacts with your customers.



Master data validation! 🚀

Learning to build your own Regex makes you an advanced user. Use these patterns in your flows to ensure that the information you capture is accurate, reducing errors and raising the quality of your bot's automated customer service. ✅

Did this answer your question?