# Match and Replace

> The example below explains how to find and match the values corresponding to a defined regular expression and replaces them with a specified value. This example uses activities such as the [Find Matching Patterns](https://docs.uipath.com/activities/other/latest/workflow/matches) and [Replace Matching Patterns](https://docs.uipath.com/activities/other/latest/workflow/replace). You can find them in the **UiPath.System.Activities** package.

The example below explains how to find and match the values corresponding to a defined regular expression and replaces them with a specified value. This example uses activities such as the [Find Matching Patterns](https://docs.uipath.com/activities/other/latest/workflow/matches) and [Replace Matching Patterns](https://docs.uipath.com/activities/other/latest/workflow/replace). You can find them in the **UiPath.System.Activities** package.

This is how the automation process can be built:

1. Open Studio and create a new **Process**.
2. Drag a **Sequence** container in the **Workflow Designer**.
   * Create the following variables:

     | Variable Name | Variable Type | Default Value |
     | --- | --- | --- |
     | `StringToAnalyze` | **String** | **"I have 10.5 RON in first account and 25 RON in second account!"** |
     | `AccountMatches` | **IEnumerable&lt;Match&gt;** |  |
     | `FinalString` | **String** |  |
3. Drag a **Matches** activity inside the **Sequence** container.
   * In the **Properties** panel, add the variable `StringToAnalyze` in the **Input** field.
   * Select the `IgnoreCase` and `Compiled` options from the **RegexOption** drop-down list.
   * Add the variable `AccountMatches` in the **Result** field.
4. Click the **Configure Regular Expression** button.
   * Select the **Advanced** option from the **RegEx** drop-down list.
   * Add the expression `([0-9]+\.*[0-9]* RON)` in the **Value** field.
   * Select the **Exactly** option from the **Quantifiers** drop-down list.
   * Select the check box for the **IgnoreCase** option.
   * Click the **Save** button.
5. Drag a **ForEach** activity underneath the **Matches** activity.
   * Inside the **ForEach** activity change the **item** to **account**.
   * In the **Properties** panel, select the **System.Text.RegularExpressions.Match** option from the **TypeArgument** drop-down list.
     + Add the variable `AccountMatches` in the **Values** field.
   * Place a **Log Message** activity inside the **ForEach** activity.
   * Select the option **Info** from the **Level** drop-down list.
   * Add the expression `account.ToString` in the **Message** field.
6. Drag a **Replace** activity below the **ForEach** activity.
   * In the **Properties** panel, add the variable `StringToAnalyze` in the **Input** field.
   * Add the value `IgnoreCase, Compiled` in the **RegexOption** field.
   * Add the expression `"$2 $1"` in the **Replacement** field.
   * Add the variable `FinalString` in the **Result** field.
7. Click the **Configure Regular Expression** button.
   * Select the **Advanced** option from the **RegEx** drop-down list.
   * Add the expression `([0-9]+\.*[0-9]* RON)` in the **Value** field.
   * Select the **Exactly** option from the **Quantifiers** drop-down list.
   * Select the check box for the **IgnoreCase** option.
   * Click the **Save** button.
8. Place a **Log Message** activity inside the **ForEach** activity.
   * Select the option **Info** from the **Level** drop-down list.
   * Add the variable `FinalString` in the **Message** field.
9. Run the process. The robot finds and matches the values corresponding to the defined regular expression and replaces them with the specified value.
* This is how your workflow should look:
  
  ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/activities-docs-image-181172-6bdffaa4.webp)

[Here](https://docexamples.uipath.com/examples/Activities/Match%20and%20Replace%20-%20Example.zip) you can download an example.
