How to remove  character in multiple lines from data extracted


I am trying to extract a file path from SharePoint, when I do that I see  this in 3 lines, and when I try .Replace(“”, “”)  gets deleted only from the first line. How do I remove it from all the 3 lines?

Hi @Harshita_Ramesh

Can you share a sample text so that i will give you the regex which will replace it entirely

Sure,
\UiPath Bots - TEST\RPA Projects\Output\Daily Stage Reports


HI @Harshita_Ramesh

Send the sample text so that we can provide you regex to conmpletely replace them.

Regards,

Hey @Harshita_Ramesh ,

Can you try below code in assign activity and check
System.Text.RegularExpressions.Regex.Replace(InputString, "^", "", RegexOptions.Multiline).ToString

Hi @Harshita_Ramesh

Try this:

Assign activity:
input= "\UiPath Bots - TEST\RPA Projects\Output\Daily Stage Reports


"
output = System.Text.RegularExpressions.Regex.Replace(yourOriginalString, "[\uE700]", "")

Hope it helps!!

This just removed the character from first line

No luck, it doesn’t remove anything

Hi @Harshita_Ramesh

Use “Assign” activity to split the text into an array of lines:

linesArray = text.Split({Environment.NewLine}, StringSplitOptions.None)
Use a “For Each” loop to iterate through linesArray:
a. Inside the loop, use an “Assign” activity to perform the replacement on each line:

currentLine = item.ToString().Replace(“”, “”)
b. Store the modified line back in the same position in linesArray.
Use an “Assign” activity to join the modified lines back into a single text:

modifiedText = String.Join(Environment.NewLine, linesArray)
Now, modifiedText should contain the text with the specified character removed from all three lines.

Hi @Harshita_Ramesh

Try this:

System.Text.RegularExpressions.Regex.Replace(input,"\n.*\n.*","")

Regards

1 Like

This worked thanks a lot :smiley:

1 Like

You’re Welcome @Harshita_Ramesh

Happy Automation
Regards,

1 Like

H! @Harshita_Ramesh

you can try in this way also by using the find matching activity…just you need pass the input and this regex (([A-Za-z\s-\])+)this will give the exact out put

you can see the out put in immediate panel

Cheers…!

Sure will try, thanks :smiley:

thanks

cheers…! @Harshita_Ramesh

1 Like

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