Ask AI
Skip to main content

Regex validate

Function: Regex validate

This action allows you to check if a piece of text perfectly matches a specific pattern you define. It's incredibly useful for validating data formats, ensuring consistency, or identifying specific structures within text without needing to write any code.

Input

  • Text: The piece of text you want to check. This is required.
  • Regex: The pattern (regular expression) that the text should match. This is required.

Output

  • Result: A variable that will store True if the text matches the pattern, or False if it doesn't.

Execution Flow

Real-Life Examples

Example 1: Validating an Email Address

You want to ensure that a user's input for an email address follows a standard format (e.g., [email protected]).

  • Inputs:
  • Result: The Result variable will be True, indicating the email format is valid.

Example 2: Checking for a Specific Product Code Format

Your product codes always start with "PROD-" followed by exactly five digits. You want to validate user-entered product codes.

  • Inputs:
    • Text: PROD-12345
    • Regex: ^PROD-\d\{5\}$
  • Result: The Result variable will be True, confirming the product code matches the required format. If the text was PROD-123 or PROD-ABCDE, the result would be False.

Example 3: Verifying a Phone Number (US Format)

You need to check if a phone number is in a common US format, like \(XXX\) XXX-XXXX.

  • Inputs:
    • Text: \(123\) 456-7890
    • Regex: ^\\(\d\{3\}\\) \d\{3\}-\d\{4\}$
  • Result: The Result variable will be True. If the text was 123-456-7890 or \(123\)456-7890, the result would be False because it doesn't exactly match the pattern (e.g., missing space after parenthesis).