Regex validate
Function: Regex validate
This action helps you check if a specific piece of text follows a certain pattern. You provide the text you want to examine and the pattern (called a 'regular expression' or 'regex'), and the action determines if the text matches that pattern. This is incredibly useful for validating data formats, such as ensuring an email address is correctly structured, a phone number follows a specific format, or a product code adheres to company standards.
Input
- Text: The piece of text you want to check against a pattern.
- Type: Text
- Regex: The pattern you want to match. This pattern should be written exactly as you would use it in a regex tester, without needing to add extra backslashes for escaping. For example, use
\sfor a space, not\\s.- Type: Text
Output
- Result: A 'True' or 'False' value indicating whether the provided text successfully matched the given pattern.
- Type: True/False
Execution Flow
Real-Life Examples
-
Example 1: Validating an Email Address Format You want to ensure that an email address entered by a user is in a valid format.
- Inputs:
- Text:
[email protected] - Regex:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]\{2,\}$
- Text:
- Result: The
Resultvariable will beTrue, because the email matches the standard format.
- Inputs:
-
Example 2: Checking for a Specific Product ID Pattern Your company's product IDs always start with "PROD-" followed by three letters and then five digits. You need to verify a new ID.
- Inputs:
- Text:
PROD-ABC-12345 - Regex:
^PROD-[A-Z]\{3\}-\d\{5\}$
- Text:
- Result: The
Resultvariable will beTrue, as the product ID follows the expected pattern.
- Inputs:
-
Example 3: Identifying an Incorrect Phone Number Format You are collecting phone numbers and expect them in the format
XXX-XXX-XXXX. You want to flag any entries that don't conform.- Inputs:
- Text:
555-1234 - Regex:
^\d\{3\}-\d\{3\}-\d\{4\}$
- Text:
- Result: The
Resultvariable will beFalse, because the provided text does not match the full phone number pattern.
- Inputs: