Regex expressions
By combining regular (regex) expressions in your JSONata expressions in , you can create complex patterns to match specific strings of text. Regex expressions are a sequence of characters that define a search pattern. It is powerful when used in text processing to find, replace, or validate strings of text. Some common uses of regex include:
- Validating email addresses or phone numbers
- Extracting specific information from a text file or document
- Reformatting data to match a specific pattern or structure
The JSONata + regex examples below create validation for text-fields in a form.
Expected results: Between 9 and 13 numbers with no spaces, can include a symbol for dialing code, e.g., +271234556789.
Expected result: [email protected]
Expected result: Typically 13-16 digits, with spaces or dashes optional, and includes checks for Visa, MasterCard, American Express, and Discover. E.g. 1111-1111-1111-1111 or 1111 1111 1111 1111.
Expected result: 5-digit codes, e.g. 10036.
Expected result: XXX-XX-XXXX
Expected result: AA123456C
Expected result: DD/MM/YYYY, e.g. 23/07/2024.
Expected result: MM/DD/YYYY, e.g. 03/28/2023.
Expected result: DD Month YYYY, e.g. 25 July 2024.
Expected result: yyyy/mm/dd, e.g. 2024/08/30.
Expected result: 1234,00
Expected result: H:MM AM/PM e.g. 12:15 AM or 08:45 PM
Expected result: MM:SS / or HH:MM, e.g. 08:10.
Expected result: 01:00
Expected result: example.com or http://example.com
Expected result: 978-1-4302-1998-9
Expected result: JohnSmith
Expected result: John Smith
Expected result: 56575 76 6