I have an InvokeCode activity which I want to convert into “Find matching patterns” and get red of invokecode activity.
I have never done that before so can someone help me with steps, how to do it.
A simple code is:
pattern = @“(?<=Best Regards)\r?\n\r?\n”;
match = Regex.Match(body, pattern);
if (match.Success) {
hold_UserName = match.Groups[1].Value;
hold_UserJobTitle = match.Groups[2].Value;
} else {
problems.Add(“Syntax Error on User name and job title”);
}
You can use the Find Matching pattern activity directly.
In the properties of Find matching pattern activity, In Text to search in pass the Variable which has Input data.
Open the Configure Regular expression, In regex option select the advanced option in the dropdown, In the value give the pattern of regular expression and save.
In the properties there is a result option create a variable in that option, the datatype is IEnumerable of Matches, which stores the extracted data from the Input data.
=> Drag and drop a “Find Matching Patterns” activity and in the properties panel of the “Matches” activity:
Set the “Input” property to your input text.
Set the “Pattern” property to your regular expression pattern (including capturing groups).
=> Create a variable to store the MatchCollection result. Let’s name it matches of type System.Text.RegularExpressions.MatchCollection.
=> Use a For Each activity to loop through the matches variable.
=> Inside the For Each loop, use another For Each activity to loop through the groups of each match.
=> Inside the loop, you can access the value of each group using the group.Value property. You can then use this value as needed in your workflow.
Consider this as an Example:
Sequence
├── Matches (Regex)
│ ├── Input: “Hello 123 and 456”
│ ├── Pattern: “\d+”
│ └── Result: matches (MatchCollection)
└── For Each (item in matches)
├── Sequence
│ └── For Each (group in item.Groups)
│ └── If (group.Name = “0”)
│ └── Log Message: group.Value
└── End For Each
I agree that match is returned.
I want to be sure that this match is true and want to put some value from that match into other variables… and if match is not true then I want to send an log message or error message.
that way i needed an IF statement which check is match true or not and that Im unable to do…