Using Regular Expressions (Regex)
Regex, or regular expressions, are powerful tools for pattern matching within strings. Despite their complex appearance, regex can be straightforward once understood and can significantly outperform ML models in terms of speed and accuracy for defined patterns.
Benefits of Using Regex
Accuracy
Regex provides high accuracy in pattern recognition for defined patterns.
Speed
Regex is faster to create and execute compared to training an ML model.
Efficiency
Regex simplifies many pattern-matching tasks once learned.
Implementing Regex in Parloa Bots
To use regex within a Storage block in Parloa, follow these steps to extract the desired entities from input text.
Step-by-Step Implementation
Example Code
Common Regex Patterns
Here are some common regex patterns you might encounter:
Flight Numbers (IATA):
[A-z]\s?\w\s?([\d]\s?){2,4}
Flight Numbers (ICAO):
([A-z]\s?){3}([\d]\s?){2,4}
German License Plates:
([A-zÃÃÃäÃŧÃļ]\s?){1,3}([A-z]\s?){2}([\d]\s?){2,4}[EeHh]?
IBAN:
([A-z]\s?){2}([\d]\s?){20}
Insurance Numbers:
([\d]\s?){9}\w
Practical Examples
Last updated
Was this helpful?