<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=445056146107513&amp;ev=PageView&amp;noscript=1">

Use of Regular Expressions to Validate Input in Meridian

Mike Space

Often in Meridian, you need to control the input of properties by users. Maybe it's whether or not it has to be a numeric entry, or perhaps it's the length that needs to be restricted. Whatever the need, using 'Regular Expressions' in the 'Validation' section of the property definition can help.

Regular Expressions can be used on 'String' properties by providing an expression to test against and a message to display if the entry fails validation.

Create Expression

Two of the most important characters to remember when defining expressions are ‘^’ and ‘$.'

  • ^ - defines the start of an expression
  • $ - specifies the end of an expression



There are many ways to validate expressions. Continuing with the example above, we can see '[0-9]. This definition allows the users to enter any number between '0' and '9'. If an alpha character is entered, the expression will fail. The second part, '{1,3}', tells the expression that the entry can be '1' to '3' numbers in length. Anything over the length of '3' will fail the test.

NOTE: The start and end characters are not required. The following shows what happens when you leave them off or use them.

  • If a caret (^) is at the beginning of a pattern, the field must begin with a string that matches the pattern.
  • If a dollar sign ($) is at the end of a pattern, the field must end with a string that matches the pattern.
  • If the expression starts with a caret and ends with a dollar sign, the field must exactly match the pattern.
  • If neither is specified, the field must contain the pattern in some section/location.

These types of regular expressions are not just for use in Meridian but can also be used in numerous programming languages, including Perl, Python, Ruby, Java, VB.NET, and C# (and any language using the .NET Framework), PHP, and MySQL.

There are numerous websites and books that can help you define these expressions. Consider the use of 'Regular Expressions' when you need to control user input on forms. They can significantly help reduce input errors.