Thursday, May 02, 2013

Regular Expression in AX 2012


How to use the regular expression to validate the number string

static void TextBuffer_RegularExpression(Args _args)
{
    TextBuffer txt = new TextBuffer();
    str msg = "9876543210";

    txt.setText(msg);

    // activate regular expr in search
    txt.regularExpressions(true);

    // Regular expression to validate only digits
    if (txt.find("^[0-9]+$"))
    {
        info("string contains only numbers");
    }
    else
    {
        info("string contains Alphanumeric characters.");
    }
}

Happy DAXing...... :)

No comments:

Post a Comment

Use Chain Of Command with Examples

 Dear Friends Here is an example of using Chain of Command for form datasource methods. [ExtensionOf(formDataSourceStr(<<Form Name>...