2012年10月29日星期一
How to using .net Regular Expression from Dynamics AX
static void THK_RegularExpression_Test()
{
int nameLen, numberLen;
str nameStr = "Vasan2th";
str numberStr = "1234";
str formatNumber, formatLetter;
boolean retName, retNumber;
System.Text.RegularExpressions.Regex regExLetter;
System.Text.RegularExpressions.Regex regExNumber;
System.Text.RegularExpressions.Match regMatch;
InteropPermission permission = new InteropPermission(InteropKind::ClrInterop);
;
nameLen = strLen(nameStr);
numberLen = strLen(numberStr);
formatNumber = strfmt(@"^[0-9]{%1}", numberLen);
formatLetter = strfmt(@"^[a-zA-Z ]{%1}", nameLen);
permission.assert();
//BP Deviation documented
regExLetter = new System.Text.RegularExpressions.Regex(formatNumber);
regMatch = regExLetter.Match(numberStr);
retNumber = regMatch.get_Success();
print "Is number format , ", retNumber; // Returns True;
regExNumber = new System.Text.RegularExpressions.Regex(formatLetter);
regMatch = regExNumber.Match(nameStr);
retName = regMatch.get_Success();
print "Is Letter format , ", retName; // Returns false;
pause;
}
订阅:
博文评论 (Atom)
没有评论:
发表评论