Hello, I’m like 2 months new to UIPath and am still going through Associate training.
I have this sudden problem that I cannot solve. Also wanted to initiate my engagement in forum too.
So I have a random pattern of document extracted every time that has spaces in the beginning, has blank rows, or just random white dashes. (Data below)
All the extracted data follow the same pattern more or less (give or take a few new lines).
My target is : To remove all unnecessary white spaces (Not between two words of a sentence) and to arrange them in their own lines for the message box.
"
Joy
Roger
12
33
I am happy
"
So this is my random string (including all the spaces) bounded with “”. My target is something like this →
“Joy
Roger
12
+
33
I am happy”
Note; if I use the replace methods, the expected gap between “I am happy” is turning out to be “Iamhappy”.
It’d be nice if it was possible without regex because I’m still practicing there. But if there’s a simple regex code too to remove the spaces, please let me know. (My attempts on regex couldn’t fully solve the issue)
I’ve browsed the forum for hours and either the methods don’t work in my sample, or too complicated for me.
A screenshot with current progress is attached. I used →
Removes the whitespaces -
Test_Data.Replace(" ", [String].Empty)
Removes the extra empty lines -
String.Join(vbCrLf, Test_Data.Split(Environment.NewLine.ToArray, StringSplitOptions.RemoveEmptyEntries))
I’ll try to understand the whole command by myself and/or reverse engineer it to figure out.
If you have any suggestion on how to get good at this, or how I’d be able to do the same by myself, please let me know. A kind explanation would be great too if you have time.
I think the important thing is to accumulate experience regarding regex. The more we write regex pattern or see and understand pattern which is written by others in various developments, the better we can write it. And regex site will also help us to understand it as @ppr shows.