Ask AI
Skip to main content

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 \s for 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

  1. 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:
    • Result: The Result variable will be True, because the email matches the standard format.
  2. 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\}$
    • Result: The Result variable will be True, as the product ID follows the expected pattern.
  3. 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\}$
    • Result: The Result variable will be False, because the provided text does not match the full phone number pattern.