I’m a beginner for UiPath. When I searched “how to remove a part of string”, there were lots of ways to achieve the result I found. Trim, slip, substring, remove,replace, etc. Actually, I know none of them. So could you please tell me how to use them or where I can find the introduction for them.
Thanks in advanced !
You’ll be using string manipulation a LOT, so it’s wise to get acquinted with it
Trim: removes leading or trailing spaces from a trim, or any other character (you can specify that as a parameter)
Substring: takes a part of the string, starting at your preferred index and then going for an x amount of characters. For example, if you have a string “Hello World” and you just want “Hello”, you’d work with: yourString.Substring(0, 5)
Remove: basically works the opposite way of substring. Where in substring you specify the part you want to keep, in remove you specify the part you want to get rid of.
Replace: replaces a part of the string with another string.
And I don’t know Slip, I don’t think that’s part of Visual Basic, the language UiPath uses.
For more info, visit the Microsoft Documentation on Visual Basic. And of course practise a lot, that’s the best way to get to know it.
Hello @Harvey, the delimiters must be in Array of Characters format, so if you only have one delimiter (like " "), you need to convert it to Array of Characters.
str1 = str1.Split(" “.ToCharArray) is the same as
str1 = str1.Split({” "c})
The ‘Split’ method will split your string into an array of substrings. As a parameter you can pass in the character to split the string on. For example, if you pass in a space (’ '), the string will be split at every occurence of a space. In UiPath you can pass it as followes: str.Split(" "c)
You can also pass in an array of characters, like indra did. In that case it will split the string between the characters in the array. In this case it retrieves all the words between the spaces. He then selects the first word in the array (‘km’) by calling the index 0.
Hi All:
now I have the string (“Language”:“ZH”,“Email”:true," ) and I want to get the ZH, but sometime maybe the Language is ZHC(for example), not only two words. So how to cut the stirng ? Thanks in advance !
yourString = yourString.Split(" ".ToCharArray)(2).ToString should do the trick. Here you split the string at every instance of a space, and then select the word at index 2, which is ‘India’.
Thank u…So index 0 would be Client in this case if I am not wrong and yourstring would be the complete CLient name: India…rite…so we are splitting here using spaces…
I have a string =“abc,def,ghi,jkl,mno,pqr,” and the result i want is to remove the last comma of the string,only the last one i.e. result = “abc,def,ghi,jkl,mno,pqr”