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:
If you found value in what I share, I've set up a Buy Me a Coffee page as a way to show your support.
Buy Me a CoffeeNo comments. Be the first one to comment on this post.
DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics 365 FO.
Authors are allowed to set their own "buy me a coffee" link.
Join us.