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
Trueif the text matches the pattern, orFalseif 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:
- Text:
[email protected] - Regex:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]\{2,\}$
- Text:
- Result: The
Resultvariable will beTrue, 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\}$
- Text:
- Result: The
Resultvariable will beTrue, confirming the product code matches the required format. If the text wasPROD-123orPROD-ABCDE, the result would beFalse.
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\}$
- Text:
- Result: The
Resultvariable will beTrue. If the text was123-456-7890or\(123\)456-7890, the result would beFalsebecause it doesn't exactly match the pattern (e.g., missing space after parenthesis).