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_.+-][email protected][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.


Raza Rabbani

Latest From Our Blog
Difference between Dynamics CRM and the Dynamic...
Record a Purchase Invoice In Dynamics AX
November 28, 2019
A lot of people tend to get confused between the Microsoft Dynamics CRM and the Dynamics AX CRM, Read our detailed comparison between dynamics crm ...
Read more
7 Ways Dynamics 365 Finance and Operations Boos...
dynamics 365 finance
November 9, 2018
Introduction Launched by Microsoft, Dynamics 365 ERP is one of the most effective for businesses today. It is perfect to save the time, effort and ...
Read more
The Ultimate Guide to Dynamics 365 HR Payroll P...
dynamics hr payroll
October 30, 2018
For any business, irrespective of its size, payroll processing is one of the most important functions. Payroll processing is a method through which...
Read more