Remove specific string values from text file

Hi I am fairly new to UiPath and trying to remove certain sentences from text file, these are fixed sentences and occur at different instances.

Eg1- Securities Settlement Instructions

Eg2- H.I. Testing Page 1 of 17 December 2, 2019Testing Instructions - for Prime Finance Clients of
U.I Securities LLC.
Registered Address: 383 Madison Avenue, New York, NY 10179

I tried to use replace activity but its giving me blank output.


you can just use replace method in assign activity:

my_string = my_string.Replace("Securities Settlement Instructions", " ")

can you share with us the Regex Pattern which you had used?

Some samples


Hi @abhishek.singh4 ,
Thanks for reaching out to UiPath Community.

You can use Regex for extracting the text you want. Please try this solution once.
Variable1 = System.Text.RegularExpressions.Regex.Replace(textContent, “Securities Settlement Instructions”, “”)

Variable2 = System.Text.RegularExpressions.Regex.Replace(textContent, “H.I. Testing Page 1 of \d+ .* Testing Instructions - for Prime Finance Clients of.* U.I Securities LLC.”, “”)

Then Write that in a message box and try it once.


Also keep in mind:
ensure that the sample input text also have more sample text as the replacement part.
We can see that input and pattern starts with Securities. When the same is also at the end (input text ends also with the same pattern end), then the empty result string is reasonable

Another regex sample for the second case jandling properly dot and line break as . is excluding a linebreak char (\n)

Hi @rikulsilva there seems to be complication error.

Please see the attached ss:

Hi @abhishek.singh4

You need change my_string to your variable that holds the text value


For example

To create Text variable you can click in Save To field in Assign Activity and press CTRL + K and give the name

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.