Regex
Checks if a given text matches a specified regular expression (regex) pattern. Regular expressions are sequences of characters that define a search pattern, primarily used for string matching and manipulation. This evaluation is crucial for validating text formats, extracting specific data, and ensuring that text adheres to predefined patterns.
Evaluation Using Interface
Input:
- Required Inputs:
- text: The content column to validate against the pattern.
- Configuration Parameters:
- pattern: String - The regular expression pattern to match against the text.
Output:
- Result: Passed / Failed
Interpretation:
- Passed: Indicates that the
text
content successfully matches the specified regexpattern
. - Failed: Signifies that the
text
content does not match the regexpattern
.
Evaluation Using Python SDK
Click here to learn how to setup evaluation using the Python SDK.
Input Type | Parameter | Type | Description |
---|---|---|---|
Required Inputs | text | string | The content to validate. |
Configuration Parameters | pattern | string | The regular expression pattern to match against. |
Output | Type | Description |
---|---|---|
Result | bool | Returns 1.0 if the text matches the regex pattern (Pass), 0.0 otherwise (Fail). |
What to do when Regex Validation Fails
Start by identifying the specific part of the text that does not match the expected pattern. Adjust the text to align with the regex requirements, ensuring it follows the intended format.
If necessary, review and refine the regex pattern to improve accuracy and prevent false negatives. Implement automated checks to validate inputs before processing, enhancing data integrity. Strengthening input validation mechanisms helps prevent formatting errors at submission.
Differentiating Regex Eval with Contains Eval
The Contains evaluation is simpler and best suited for basic keyword searches, while Regex offers greater complexity, enabling advanced pattern matching with wildcards, character classes, and quantifiers.
Contains is limited to exact keyword matches, whereas Regex provides flexibility for matching complex patterns and conditions.
Was this page helpful?