# Regex Replace Challenge

**URL:** <https://forum.uipath.com/t/regex-replace-challenge/19555>\
**Category:** Help\
**Tags:** studio, regex\
**Created:** [January 15, 2018, 8:36pm UTC](https://forum.uipath.com/t/regex-replace-challenge/19555 "2018-01-15T20:36:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![hangon](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hangon/32/176690_2.png) [@hangon](https://forum.uipath.com/u/hangon)\
**Post date:** [January 15, 2018, 8:36pm UTC](https://forum.uipath.com/t/regex-replace-challenge/19555/1 "2018-01-15T20:36:07Z")

</div>

I have a string like below  
**This is a test and the Test is part of unit testing**

I want to replace all the “test” with “xxxtestxxxx” so the output should be  
This is a **xxxtestxxxx** and the **xxxTestxxxx** is part of unit testing → (including the original cases(test/Test)

I’m using the following function  
System.Text.RegularExpressions.Regex.Replace(“string”,“regexpattern”,“replacestring”)  
System.Text.RegularExpressions.Regex.Replace(tempString,“(?i)\btest\b”, “xxxtestxxxx”)

My challenge is how do I access the matched expressesion ouput (2nd parameter) in the last parameter replacestring…

I hope I made myself clear…

---

<div class="post-metadata">

**Author:** ![hangon](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hangon/32/176690_2.png) [@hangon](https://forum.uipath.com/u/hangon)\
**Post date:** [January 20, 2018, 12:47am UTC](https://forum.uipath.com/t/regex-replace-challenge/19555/2 "2018-01-20T00:47:57Z")

</div>

any help ?

---

<div class="post-metadata">

**Author:** ![vvaidya](https://avatars.discourse-cdn.com/v4/letter/v/e56c9b/32.png) [@vvaidya](https://forum.uipath.com/u/vvaidya)\
**Post date:** [January 20, 2018, 12:52am UTC](https://forum.uipath.com/t/regex-replace-challenge/19555/3 "2018-01-20T00:52:32Z")

</div>

> [@hangon](#):
>
> xxxtestxxxx

Why not use String.Replace

For eg

Str.ToLower.Replace(“test”,“xxxtestxxxx”)

---

<div class="post-metadata">

**Author:** ![arivu96](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@arivu96](https://forum.uipath.com/u/arivu96)\
**Post date:** [January 20, 2018, 2:14am UTC](https://forum.uipath.com/t/regex-replace-challenge/19555/4 "2018-01-20T02:14:03Z")

</div>

Hi,

System.Text.RegularExpressions.Regex.Replace(tempString,“((\btest\b)+”, “xxxtestxxxx”)

Regards,  
Arivu

---

<div class="post-metadata">

**Author:** ![hangon](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hangon/32/176690_2.png) [@hangon](https://forum.uipath.com/u/hangon)\
**Post date:** [January 20, 2018, 7:09pm UTC](https://forum.uipath.com/t/regex-replace-challenge/19555/5 "2018-01-20T19:09:18Z")

</div>

thanks for the replies… the above suggestions may not work for me…  
what I want is the input string could be case sensitive… so for ex : “test” or “Test” or “teST” etc., and the replacement should happen

**xxxtestxxx**  
**xxxTestxxx**  
**xxxteSTxxx**

with the above suggestions I will not be able to get that… hope I clarified…

---

<div class="post-metadata">

**Author:** ![vvaidya](https://avatars.discourse-cdn.com/v4/letter/v/e56c9b/32.png) [@vvaidya](https://forum.uipath.com/u/vvaidya)\
**Post date:** [January 20, 2018, 8:55pm UTC](https://forum.uipath.com/t/regex-replace-challenge/19555/6 "2018-01-20T20:55:01Z")

</div>

[stringReplace.xaml](https://global.discourse-cdn.com/uipath/original/2X/5/5e6369f14db154cf66630993ebe7e0b377b361d9.xaml) (7.5 KB)

---

<div class="post-metadata">

**Author:** ![harinathreddy.yn](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/harinathreddy.yn/32/213599_2.png) [@harinathreddy.yn](https://forum.uipath.com/u/harinathreddy.yn)\
**Post date:** [April 27, 2018, 2:31pm UTC](https://forum.uipath.com/t/regex-replace-challenge/19555/7 "2018-04-27T14:31:22Z")

</div>

can you help me with pattern for page numbers of a pdf like 1/1 or 1/2 or 1/10 which needs to be replaced with empty string

---

<div class="post-metadata">

**Author:** ![hangon](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hangon/32/176690_2.png) [@hangon](https://forum.uipath.com/u/hangon)\
**Post date:** [April 27, 2018, 3:43pm UTC](https://forum.uipath.com/t/regex-replace-challenge/19555/8 "2018-04-27T15:43:11Z")

</div>

Hi - here is the example

> pattern - (\d\*/\d\*)

in UiPath assign activity you an probably achieve like below [did not test… but it should work]

> System.Text.RegularExpressions.Regex.Replace(yourstring,“(\d\*/\d\*)/g”, “”,“”)

---

<div class="post-metadata">

**Author:** ![harinathreddy.yn](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/harinathreddy.yn/32/213599_2.png) [@harinathreddy.yn](https://forum.uipath.com/u/harinathreddy.yn)\
**Post date:** [April 27, 2018, 3:52pm UTC](https://forum.uipath.com/t/regex-replace-challenge/19555/9 "2018-04-27T15:52:26Z")

</div>

Its working bro, thank you so much for help.
