Matches

This activity helps you to locate and handle required data from a large string of characters.

Technical Reference

 

 

 

   INPUT

InputString: Enter the input string to which the Regex pattern has to be applied.

Pattern: Enter the Regex pattern to be used.

RegexOption: Choose from the drop-down menu.

 

 

 

 

 

 MISC

Display Name: Displays the name of the activity. You can also customize the activity name to help troubleshoot issues faster. This name will be used for logging purposes.

SkipOnError: It specifies whether to continue executing the workflow even if it throws an error. This supports only Boolean value “True or False”

True: Continues to execute the workflow irrespective of any error thrown.

False: Stops the workflow if it throws any error

Version: It specifies the version of the Regex Automation feature in use.

OUTPUT

MatchResults: Declare a variable here to view the result. This is not a mandatory field however declare a variable to get the result.

* Mandatory fields to execute the workflow.

Use Case

The following example illustrates on how are going to use the Matches activity to
retrieve the primary and secondary email id from the given string. Here we are using 
an input string from the notepad and extracting the primary and secondary email id 
from the string using a specific regex pattern.

Steps to execute the bot

1.Drag and drop a sequence activity.

2.Double click on the activity. Drag and drop a matches activity into the sequence
activity.

3.Click on the matches activity and enter the created variable in the input string box.

4.In the Regex pattern box, enter the regex pattern that is used to retrieve the Email id. The pattern
used here is "(?:[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])?|\[(?:(?:25[0-5]|2[0-4][0-9]
|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-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])+)\])"
 

5.In the Regex option box, check the condition boxes which has to be applied to retrieve
the required result. Here we do want any condition to be applied, so we choose None.

6.Declare a variable in the MatchResults box. Here the variable is Output.

7.Drag and drop a Foreach activity below the matches activity.

8.Click on the ForEach activity and change the type argument to string.

9.In the Values box, enter the variable that was declared in the matches results of the
Matches activity.

10.Drag and drop a write log activity below the matches activity to view the result of the
retrieved data.

11.Enter the input string as “Email:” + item

12.Enter the log level as “info”.

13.Execute the activity to see the email id in the output box.
 

The bot executes the activity and gives both the email ID in the output box.