When working with strings, ex. replacing text, validating content or simply checking for existence, It can sometimes be a good idea to consider using Regular Expressions (RegExp), insted of using ordinary string manipulation methods.
X++ itself does not seem to support Regular Expressions, but we can use the .NET functionality.
Below is an example method of how to validate that an email address is written in a proper format.
It simply returns true if the input is a properly formatted email.
To replace text in a string you could do something like this:
image.png
This will replace ALL found email addresses.
Below is an example of how to “find” all matches.
image.png
Notice the difference between the RegExp pattern in this example and the first example.
The first pattern checks if the input is valid.
And this pattern checks for ALL valid matches.
For more information about regular expressions visit:www.regular-expressions.info
原文地址:http://fourone.se/blog/2009/10/02/using-regular-expressions-in-dynamics-ax/










网友评论