Good afternoon people,
I would like to check with you what is the best way to remove line breaks and whitespace from a string.
I’ve tried several alternatives but I have not had success yet
I’ve exported my string to the Execution Log to see how it looks.
This is my String:
“\n---------------201900000020496\n---------------”
Hyphens “-” represent the whitespace
“\ n” represent line breaks
How UiPath Captures Element Text:
How the Element displays the text:
I tried treatments like LTRIM() and RTRIM() but it did not work
Hi buddy @Rafaeloneil
Instring = " \n 201900000020496\n"
Better one is this, the reason is it will remove all the newline in a paragraph and make them as single line…this can be used for a paragraph as well… stringResult= Regex.Replace(instring, “\t|\n|\r”, “”)
Or StringResult = instring.Replace(Environment.newLine,“”)
or if its just a space we can use trim method of string class buddy
like this if your get text is stored in a variable of name intext
then intext = intext.ToString.Trim
Trim is a method that would trim both the trailing and leading empty spaces of a string
where the method that were used previously like LTRIM and RTRIM mentions LEFT TRIM and RIGHT TRIM…that would trim only in the specific direction like either before or after the string buddy, thats why that didn’t work
Fine this would work for sure or
Any issues still buddy @Rafaeloneil
When Assigning my treated string to a cell in my DataTable is a warning: Cannot Assign from type ‘System.String’ to type ‘UiPath.Core.GerericValue’ in Assign Activity ‘Assign’
Hi buddy’s
I already solved the problem, my field in the table had to be changed to string instead of number, from that point the assing worked.
Many thanks to all for the help