Regular expressions in Dynamics AX

In all versions of Dynamics AX, the Find window supports regular expressions. Recently I discovered that even the label editor supports regular expressions.

Using regular expressions in the find window and the label editor can significantly reduce your search times and you can narrow down your search to exactly what you are searching for.

Let us look at some example.

Suppose I want to search for all classes which have methods which are named like the following,

enable(Any text here)Buttons.

So all names like enableActivityButtons, enableDisableButtons, enableAllButtons etc should be found.

So, we first need to analyze our expression requirement. Our search string should start with enable.

For that, we need to enter <enable. The < character matches the specified string at the start of the string.

Similiarly, for matching Buttons at the end of the string, we need to specify Button>. The > character matches the specified string before it at the end of the string.

So, will just giving <enablebuttons> in the find window work?

The answer is no because this pattern will try to match a method name which is just enableButtons. But we are looking for some text between enable & buttons. To specify this we need to use the :a+ combination.

:a means match any character and + suggests matching 1 or more occurences of the preceding character.

So our complete match pattern should be <enable:a+Buttons>

So if you enter this, it will search for all methods which have a name patter like this.
As you can see in the above image, all method names which begin with enable and end with Buttons has been fetched.

Similiarly, you can also use these regular expressions in the label editor as well.

Suppose, I want to see if I have a label like "Cannot copy the information to the source". Now, I can straight forward enter the label and try to find it. But I would also like to see what other variations may exists. So, even if the label is "Cannot copy the data to the %1", I can still reuse it. So to search for such labels, I formulate my pattern like <Cannot copy

This way, all labels which start with Cannot copy will be fetched.

At first, using regular expressions may feel like a pain but they are very powerful and will speed up your searches.

For a complete list of pattern formulation, check the Match function on MSDN.


Use the help for AX function "match" to see a list of the possible regexp wildcards.
Fawad said…
Nice article zubair. keep it up
Fawad said…
Nice article zubair, keep it up

Popular posts from this blog

How to add empty ranges in query

Get selected records in Dynamics AX 2012

The field with ID '0' does not exist in table - Cause and resolution.