Returns the number of matches for the regular expression pattern on the entity property value.
Target parameters (in) and Activity options
Entity |
The entity used for the property value. |
Property |
The property for the value to count matches on. |
Pattern |
The regular expression patterns. You can write more than one pattern by using “#REGEX#” as delimiter between them.
The pattern is used in the C# Regex class see Regex Class (System.Text.RegularExpressions) | Microsoft Docs.
|
Source parameters (out)
MatchCount |
The number of matches for all given patterns. |
Example
Another example
As a developer you might want to validate user entered values in a field. Such as email addresses so it does not include faulty characters, and that the structure of the email looks correct.
You can use the "Regular Expression" to do this. We can look at this example below:
In my workflow that edits one of my entities called "Customer" I have a field called email. When a user has edit this value I want to check that the values are correct.
Regular Expression
- Place "Regular Expression Activity" after the dialog view in the process
- Make sure that the newly added activity is before the "Commit"
- Bind the entity to the regular expression
- Click on "Regular Expression"
- Select the email property
- Paste this the value below into the "Pattern"
- (?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
Adjust the "Commit"
- Add a criteria on incoming branch to the "Commit" activity.
- [MatchCount] = 1
- If the entered value matches our pattern/expression and the workflow will commit
Show a waring message if value is faulty
- Drag a "Show message Box" and drop it on the "Regular Expression" activity.
- Edit some informational text into the Message Box.
- Add an additional branch, by pressing "Add Branch"
- Select the "Dialog View" (Edit) as "Sourcestep"
- Save the workflow and verify that the newly added function works as supposed.
Comments
0 comments
Please sign in to leave a comment.