MIDAS Knowledge Base MIDAS Knowledge Base

How to use Regular Expressions for custom input validation

A regular expression - or REGEX - is a sequence of characters that specifies a match pattern in text.

In MIDAS, Regular Expressions can be used to validate entries into custom input fields.

For instance, you could use a Regular Expression to ensure that an input is of a certain length, only contains certain characters, or matches a specific format.

Regular expressions can be very powerful and versatile tools. However, they can also be difficult to learn and use.

Simple Regular Expression Examples

DescriptionREGEXExample That MatchesExample That Doesn't Match
Match any value.MIDAS
Value must start with the letters "BOOK"^BOOKBOOKEDBLUEBOOK
Value must end with the letters "ING"ING$BOOKINGBOOKED
Value must contain "BOOKING"BOOKINGYOUR BOOKING DETAILSYOU BOOKED
Value must be exactly "BOOKING"^BOOKING$BOOKINGYOUR BOOKING
Value must contain a number (digit)\d2 BOOKINGSTWO BOOKINGS
Value must not contain a number (digit)\DTWO BOOKINGS2 BOOKINGS
Value must be exactly "BOOK", followed by two single digit numbers^BOOK\d\d$BOOK43BOOKING43
Value must start with "BOOK", followed by a three single digit number^BOOK\d{3}BOOK432BOOK43
Value must contain "BOOK", followed by either a number 1, 2, or 3BOOK[1-3]BOOK2BOOK4
Value must start with any uppercase letter ^[A-Z]Abc123abc123
Value must end with any lowercase letter[a-z]$123abcabc123
Value must be at least 5 characters in length.{5}BOOKINGBOOK
Value must be exactly 4 characters in length^.{4}$BOOKBOOKING
Match a number in the format ###-###-####\d{3}-\d{3}-\d{4}123-456-7890123-4567-890

Explanation

Here's an explanation of some of the REGEX characters you'll have noticed in the above examples:

ExpressionsMeaning
^Matches at the start of a value
$Matches at the end of a value
.Matches any character
\dMatches any single number (digit)
\DMatches any single character that's not a number (digit)
{3}Matches the preceding expression three times
[A-Z]Matches any uppercase letter between A and Z
[a-z]Matches any lowercase letter between A and Z
[A-Za-z]Matches any letter between A and Z, regardless of case
[1-3]A number in the range 1 - 3

You might also be interested in...


MIDAS » KB » Support » Article 00246

← Return to the Knowledge Base