Regular expressions

There are two kinds of regular exressions that you can use in Ax

Internal
You can use the match function to check whether a string matches a regular expression or the TextBuffer class to find a sub string which matches a regular expression. Internal regular expressions have a very special syntax, which is described in a help for the match function in Ax 3.

boolean isCorrectPhone(str _s) {   return match('<:d:d:d-:d:d-:d:d>', _s); }

Reference (to be reformatted )
Compares the fixed expression specified by pattern with the text string specified by text.

The system does not differentiate between lower and upper case.

A combination of fixed expressions is in itself a fixed expression.

The following special characters can be used to create the pattern in the fixed expression:

\ A backslash causes a specific character to be matched. For example, "\$" matches a dollar sign.

< or ^ A 'less than'(<) sign or a circumflex (^) at the start of an expression is used to match the start of a line. > or & A 'greater than'(>) sign or an ampersand (&) at the end of the expression is used to match the end of a line. ? or. A question mark (?) or a full stop (.) will match any character (except Enter, new line).
 * x A colon specifies a group of characters to be matched, indicated by the character which follows immediately after.
 * a Sets the match to letters
 * d Sets the match to numeric characters
 * n Sets the match to alphanumeric characters
 * SPACE  Sets the match to blanks, tabulations, and control characters such as Enter (new line).


 * An expression followed by an asterisk requires a match for none or several occurrences of the expression.

For example, "fo*" will locate "f", "fo", "foo" etc. + An expression followed by a plus (+) sign requires a match for one or several occurrences of the expression.

For example, "fo+" matches "fo" etc. - An expression followed by a minus (-) sign requires a match for no or one occurrence of the expression.

For example, "fo-" matches "f" and "fo". [] A string of characters enclosed within square brackets specifies that a match is required for every character in this text, and only for these characters.

For example, "[xyz]" matches "xx" and "zyx" etc.

A string of characters can be specified by two characters separated by '-' (minus). For example, "[a-z]" matches all letters, whereas "[z-a]" never matches. [^] If the first character in a text within square brackets is a circumflex (^) then the expression matches all characters except Enter (new line) and the characters in the string.

For example, "[^xyz]" matches "abc" but not "axb".

Выходное значение

External
You can use more rich regular expressions via COM in Ax 3 or .NET in Ax 4

Ax 4 business code uses System.Text.Regex for many purporses such as email validation ( \Classes\SysEmailDistributor\validateEmail )