Split Function in UiPath: Syntax and Examples

Formulas & functions · Updated November 23, 2026

The Split function in UiPath is a method used on strings to divide them into an array of substrings based on a specified delimiter or set of delimiters. In UiPath, you can use it in expressions with .NET syntax, such as "apple,banana,cherry".Split(","c), which returns an array of three strings. This function is essential for parsing CSV data, log files, or any delimited text within your automation workflows.

What Is the Split Function and Why Use It?

UiPath is built on .NET, so its string manipulation methods come directly from the .NET framework. The Split method is one of the most frequently used string functions in RPA development because it lets you break a single string into manageable parts. For example, when you read a line from a text file that contains comma-separated values, you can split that line into individual fields and then process each field separately. Without Split, you would have to write complex loops or use other functions like Substring, which is error-prone and time-consuming.

The Split function is available in UiPath’s Expression Editor, which you can access in activities like Assign, If, or For Each. You can use it directly in a VB.NET expression, as UiPath uses Visual Basic syntax for expressions. This means you can combine Split with other .NET functions, loops, and conditional logic to build powerful data-processing workflows.

How to Use Split in UiPath: Syntax and Basic Examples

In UiPath, the Split method is called on a string variable or literal. The simplest syntax is:

yourString.Split(delimiter)

Here, delimiter can be a character or an array of characters. In VB.NET, you specify a character literal with a trailing c (e.g., ","c). For example, to split a string by a comma:

Dim input As String = "John,Doe,30"
Dim parts() As String = input.Split(","c)
' parts(0) = "John", parts(1) = "Doe", parts(2) = "30"

In a UiPath Assign activity, you would write:

parts = input.Split(","c)

If you want to split by a string (like “, “), you need to use the overload that accepts a String array and StringSplitOptions:

parts = input.Split(New String() {", "}, StringSplitOptions.None)

You can also split by multiple characters at once. For instance, to split by both comma and semicolon:

parts = input.Split(New Char() {","c, ";"c})

This will split the string at every occurrence of either character.

Splitting by Multiple Delimiters and Handling Empty Entries

When your data contains consecutive delimiters (e.g., “apple,,banana”), the default Split method will include empty strings in the resulting array. To remove empty entries, use the StringSplitOptions.RemoveEmptyEntries option:

parts = input.Split(New Char() {","c}, StringSplitOptions.RemoveEmptyEntries)

This is particularly useful when parsing CSV files where some fields may be blank. However, be careful: removing empty entries changes the array indices, so if you need to preserve the position of each field (for example, to map to a fixed column structure), you should keep the empty entries and handle them later.

Another common scenario is splitting a full name into first and last name. For example:

fullName = "Jane Smith"
nameParts = fullName.Split(" "c)
' nameParts(0) = "Jane", nameParts(1) = "Smith"

But what if the name has a middle name? You can check the array length and concatenate accordingly.

Using Split with For Each to Process Data

One of the most powerful ways to use Split is inside a For Each loop. For instance, if you have a multiline string containing multiple records, you can first split by newline, then split each line by a delimiter. Here’s a typical pattern:

  1. Use an Assign activity to read the entire text into a string variable (e.g., fileContent).
  2. Split fileContent by Environment.NewLine to get an array of lines.
  3. Use a For Each activity to iterate over each line.
  4. Inside the loop, split each line by comma to get fields.
  5. Process the fields as needed (e.g., write to a DataTable or log).

Example expression to split by newline:

lines = fileContent.Split(New String() {Environment.NewLine}, StringSplitOptions.None)

Note that if the file uses only \n (Unix) instead of \r\n (Windows), you may need to split by "\n"c instead. To handle both, you can replace \r\n with \n first:

normalized = fileContent.Replace(vbCrLf, vbLf)
lines = normalized.Split(vbLf)

Common Pitfalls and How to Avoid Them

One common mistake is forgetting the c suffix when using a character literal. In VB.NET, "," is a string, not a character, so Split(",") will not compile. Always use ","c for a character delimiter.

Another pitfall is splitting by a string delimiter incorrectly. The overload that accepts a string requires a String array, not a single string. So Split(", ") is invalid; you must use Split(New String() {", "}, StringSplitOptions.None).

Also, be aware that the Split method is case-sensitive. If you need to split by a word regardless of case, you may need to use a different approach, such as using Regex.Split from the System.Text.RegularExpressions namespace, which allows case-insensitive patterns.

Finally, remember that the Split method returns an array. If the delimiter is not found, it returns an array with one element containing the entire original string. This is often unexpected, so always check the array length if you assume a certain number of parts.

Split vs. Other String Functions in UiPath

UiPath offers several string functions that can be used instead of or alongside Split. For example, Substring extracts a portion of a string based on index and length, which is useful when you know the exact position of the data. Replace substitutes occurrences of a substring, which can be used to change delimiters before splitting. Regex.Match and Regex.Split provide pattern-based splitting, which is more flexible for complex delimiters like multiple spaces or variable punctuation.

Here’s a quick comparison:

  • Split: Best for fixed, simple delimiters like commas, tabs, or spaces.
  • Substring: Best when you know the exact start index and length.
  • Regex.Split: Best for complex patterns, such as splitting by digits or multiple spaces.
  • Replace: Often used to normalize data before splitting.

For example, if you have a string like “ID: 123, Name: John”, you could use Regex.Split with a pattern to extract the values, but a simpler approach might be to replace the labels and then split by comma.

Practical Example: Parsing a CSV Line in UiPath

Suppose you have a CSV line: "Alice,25,New York". To extract the name, age, and city into separate variables, you can do the following:

  1. Assign line = "Alice,25,New York".
  2. Assign fields = line.Split(","c).
  3. Now fields(0) is “Alice”, fields(1) is “25”, and fields(2) is “New York”.
  4. You can convert the age to integer using CInt(fields(1)) if needed.

If the CSV line contains quoted fields with commas inside (e.g., "Doe, John",30), then a simple Split won’t work correctly. In that case, you should use a proper CSV parser, such as the UiPath.CSV activities or a .NET library like Microsoft.VisualBasic.FileIO.TextFieldParser. For most simple cases, Split is sufficient.

Frequently Asked Questions

Can I split a string by a newline in UiPath?

Yes, you can split by newline using yourString.Split(New String() {Environment.NewLine}, StringSplitOptions.None). If your string uses only \n (Unix line breaks), use yourString.Split("\n"c). For files with mixed line breaks, normalize first with Replace.

How do I split a string into a list instead of an array?

In UiPath, you can convert the array to a List using yourArray.ToList() (requires System.Linq). For example: myList = myString.Split(","c).ToList(). This is useful when you need to add or remove items dynamically.

What is the difference between Split and Regex.Split in UiPath?

Split uses a literal delimiter character or string, while Regex.Split uses a regular expression pattern. Regex.Split is more powerful for complex delimiters, such as splitting by any number of spaces or by a pattern like digits. However, Regex.Split is slower and can be harder to read.

Why does my Split return an array with one element even when the delimiter is present?

This usually happens if you used a string delimiter incorrectly (e.g., Split(",") instead of Split(","c)). The first one tries to split by the string “,” but the method expects a character, so it may throw an error or behave unexpectedly. Always use the correct overload.

Can I split a string by multiple different delimiters at once?

Yes, you can pass an array of characters to Split: yourString.Split(New Char() {","c, ";"c, "|"c}). This will split at any of those characters.

Is Split case-sensitive in UiPath?

Yes, the built-in Split method is case-sensitive. If you need case-insensitive splitting, you can use Regex.Split with the RegexOptions.IgnoreCase option, or convert the string to lowercase before splitting (but that changes the data).

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.