Showing posts with label Ax2012 string as real. Show all posts
Showing posts with label Ax2012 string as real. Show all posts

Tuesday, June 12, 2018

validate given string as real value

static void ValidateReal(Args _args)
{
    System.Text.RegularExpressions.Regex re;
    boolean retval;
    str     test = "0.178010";

    re = new System.Text.RegularExpressions.Regex ('^\\s*[+\\-]?\\s*[0-9]+?\\s*\.?\\s*[0-9]+\\s*$');

    retval = CLRInterop::getAnyTypeForObject(re.IsMatch(test));

    if(retval)
    {
        info("real value");
    }
    else
    {
        info("string value");
    }

}