Regex Replace Challenge



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(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…


any help ?


Why not use String.Replace

For eg




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



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


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


stringReplace.xaml (7.5 KB)


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


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", “”,"")


Its working bro, thank you so much for help.