Saturday, February 4, 2012

How to use the regular expression to validate the name in X++ AX

How to use the regular expression to validate the name

public bool validateName(str _name)
{

    System.Text.RegularExpressions.Match regExMatch;
    bool                                 isValid;

    // verify that Name doesn’t contain bad special character like <>:”/\|?*
    // other characters used in the regular expression are part of regex syntax. 

    regExMatch = System.Text.RegularExpressions.Regex::Match(_name, @’^[^<>:"/\\|?*]*$);
   
    // return true if name matches the criteria otherwise return false
    isValid = regExMatch.get_Success();   

    return isValid;
}

1 comment:

  1. useful artical, i have one doubt. how to set the page break in ax2009 standard reports

    ReplyDelete