Updated April 3, 2023
Introduction to UiPath split string
UiPath Split string is the method, function, or feature provided in UiPath that helps split the source string that is supplied or specified and get the substrings of it as per the delimiters or characters specified. In this article, we will try to understand what UiPath split string is, how to use a UiPath split string, UiPath split string method, UiPath split string examples, and UiPath split the string, and finally conclude our statement.
What is a UiPath split string?
The string is formed by collecting the characters; in other ways, we can also say that string is the array of characters. In UiPath, the splitting of the string is getting the substrings according to the specified terms. The method of a split in UiPath helps to mention the delimiters or the characters in the format of Unicode. This can also be an array of unicoded characters used to form the substrings of the source string using the split method.
How to UiPath split string?
We can make the split method to split the supplied source string into substrings that are decided per the delimiter we will specify. We can even specify the array of characters or strings that will be considered for delimiting the source string. If we don’t specify any delimiters in the method, whitespace is considered for separating and forming the substrings from the source string.
UiPath split string Method
UiPath split method has many overloaded variations of it. This method helps split the main string into substrings by using a delimiter to specify their separation in the source string.
There are various overloaded variations of the split method that accept different numbers and types of parameters, but the most generally used one is as described below –
Split (source string, options for splitting)
Other versions of the split method and overloaded formats/ syntaxes are provided in the below table, along with its description –
Overloaded syntax | Description |
Split ( delimiter character, number in int32, options of splitting the source string) | This overloaded syntax is used for gaining the maximum number of splitted substrings from the source string considering the specified delimiter; it also considers the options that can be mentioned on an optional basis. This variant can also omit the empty substrings in the final resultant output. |
Split (array of string, number in int32, options of splitting the source string) | This overloaded syntax is used to gain the maximum number of splitted substrings from the source string considering the specified delimiter. It also considers the options that can be mentioned on an optional basis. |
Split ( array of characters, number in int32, options of splitting the source string) | This overloaded syntax is used to gain the maximum number of splitted substrings from the source string considering the specified delimiter. It also considers the options that can be mentioned on an optional basis. |
Split ( string array, options of splitting the source value) | This overloaded syntax is used to gain the splitted sub-string from the source string considering the specified delimiter. It also considers the options that can be mentioned on an optional basis. |
Split ( source string value, number in int32, options of splitting the source value) | This overloaded syntax is used to gain the maximum number of splitted substrings from the source string considering the specified delimiter. It also considers the options that can be mentioned on an optional basis. |
Split ( character array, options of splitting the source value ) | This overloaded syntax is used to gain the maximum number of splitted substrings from the source string considering the specified delimiter. It also considers the options that can be mentioned on an optional basis. |
Split (character, options of splitting string) | This overloaded syntax is used to gain the splitted sub-string from the source string considering the specified delimiter. It also considers the options that can be mentioned on an optional basis. |
Split (character array, int 32 number) | Used to gain the maximum number of substrings splitted using delimiter from the source string. |
UiPath split string examples.
Let us consider some examples to help us understand the split method’s implementation in UiPath.
Example #1
Code:
string sampleEducbaString = "We achieve it. We learn it.";
string[] resultedSubstring = sampleEducbaString.Split(' ');
foreach (var individualSubstring in resultedSubstring)
{
Console.WriteLine($"Received splitted string : {individualSubstring}");
}
After executing the above program, we get the following output –
As you can observe, what we passed as a parameter was just one delimiter. Hence, all the white spaces were considered the point of separation for forming the substrings’ splitted strings.
Example #2
Code:
string sampleEducbaString2 = "We achieve it. We learn it.";
string[] resultedSubstrings = sampleEducbaString2.Split(' ', '.');
foreach (var individualSplit in resultedSubstrings)
{
Console.WriteLine($"Received splitted string : {individualSplit }");
}
After executing the above program, we get the following output –
We can observe that as we specified the whitespace and the period dot(.) as the delimiter in the array, we got that the splitted strings even contained two empty strings separated because of the period delimiter.
Example #3
Code:
string educbaSampleString3 = "We achieve it. We learn it.";
char[] delimiters = new char[] { ' ', '.' };
string[] resultedSubstrings = educbaSampleString3.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
foreach (var individualSubString in resultedSubstrings )
{
Console.WriteLine($"Received splitted string : {individualSubString }");
}
After executing the above program, we get the following output –
We can omit the problem of getting blank empty strings in the above example simply by passing the character array of separators and the option of removing the empty entries.
Conclusion
The UiPath Split method is used to get the substrings from the source string, which are formed by considering the specified delimiter(s) as the point of splitting. This method has various overloaded syntaxes, as discussed in the above section.
Recommended Articles
We hope that this EDUCBA information on “UiPath Split String” was beneficial to you. You can view EDUCBA’s recommended articles for more information.