From July 9th till 13th we will be at #MSInspire. See you there!

Regular Expression in Dynamics AX 2012

Regular Expression in Dynamics AX 2012
15 Jan 2015

Hi Guys,

In this post we’ll be looking at Regular Expression in Dynamics AX 2012. As you know, working with strings involves working with methods for searching text, validating names and emails, replacing text, etc. Whenever you need to use string manipulation methods for such tasks, it might be a good idea to use Regular Expression instead. Let’s take a look at how we can use Regular Expression in Dynamics AX 2012.

The term Regular Expression (regex or regexp for short) is an exceptional text string for describing a search pattern. Think of it as a wildcard notation on steroids. I’m sure you’re familiar with wildcard notations like for example the *.txt notation, that is used to search all text files in a file manager. The equivalent Regular Expression (regex) for this would be *.txt$.

Dynamics AX also provides extensive support for regular expression. Given below is some sample code that is used for email validation – via Regular Expression in Dynamics AX.

static void TestJob(Args _args)
boolean isValidEmail;
System.Text.RegularExpressions.Match myMatch;
System.Text.RegularExpressions.Regex regex;

//passing regular expression in parameter
regex = new System.Text.RegularExpressions.Regex(@’^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$’);

//passing email address to validate
myMatch = regex.Match(‘[email protected]’);
isValidEmail = myMatch.get_Success();

//displaying whether email is valid or not
info(strfmt(‘Is Email Valid: %1’,isValidEmail));


Feel free to comment if you have any questions.

About Folio3 Dynamics Services

FDS (Folio3 Dynamics Services) is a dedicated division of Folio3 that specializes in Microsoft Dynamics AX, Dynamics CRM, Dynamics NAV and Dynamics GP based development, customization and integration services. Our main focus is on Enterprise Mobility. We firmly believe that opening up Microsoft Dynamics AX and other products to iOS Android, Windows 8 and Windows Phone users will have a huge impact on organizational agility and productivity.


Noc Folio3