static void RegularExpressionMatch(Args _args) { str text = '123'; if (match("^[0-9]+$", text)) { info("It number"); } info("done"); }Find several entries:
static void RegularExpression(Args _args) { str MatchEmailPattern = @"\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b"; // string contains several email that we should find str text = "Your email: youremail@host.net, and my email: myemail@anotherhost.com"; System.Text.RegularExpressions.Match myMatch; ; myMatch = System.Text.RegularExpressions.Regex::Match(text, MatchEmailPattern); while (myMatch.get_Success()) { info(myMatch.get_Value()); myMatch = myMatch.NextMatch(); } }Regular expression with groups
static void RegularExpressionGroups(Args _args) { System.Text.RegularExpressions.Match regMatch; TreeNode treeNode; str macroList, regExp; int gCounter = 0; System.Text.RegularExpressions.Regex re; System.Text.RegularExpressions.GroupCollection gc; System.Text.RegularExpressions.Group regGroup; ; treeNode = TreeNode::findNode('\\macros\\SysBPCheck'); macroList = treeNode.AOTgetSource(); regExp = strFmt(@"\.(\S+)\(%1", 276); re = new System.Text.RegularExpressions.Regex(regExp); regMatch = re.Match(macroList); if (regMatch.get_Success()) { //info(regMatch.get_Value()); gc = regMatch.get_Groups(); gCounter = gc.get_Count(); if (gCounter > 1) { regGroup = gc.get_Item(1); info(regGroup.get_Value()); } } }Regular Expression Syntax:
DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.
Authors are allowed to set their own AdSense units.
Join us.