2012年6月21日星期四

How to using X++ code to validate only numbers in string

Following job that illustrates how we can use regular expressions in axapta for validating only numbers in string.

static void THK_regularExpression(Args _args)
{
    TextBuffer  txt = new TextBuffer();
    str         msg = "9877897";
;
    txt.setText(msg);
    txt.regularExpressions(true); // activate regular expr in search
    // Regular expression to validate only digits
    if (txt.find("^[0-9]+$"))
    {
        info("string contains only numbers");
    }
    else
        warning("This string have not all numbers");
}

没有评论:

发表评论