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.
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.
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 !