.split(" "c) - what is 'c'?

In the split function, I understand " " (space is the delimiter), but what is ‘c’?

7 Likes

Hi,
Splits a string into substrings that are based on the characters in an array.
Example1
Example2

3 Likes

Hi,

Please follow the below tutorial, on split and join string operations.

thanks,
Karthik.

2 Likes

my apologies but I still do not understand what the c means, is it meant to tell the computer that the variables are characters?

1 Like

.Split argument needs “Char”(Character) type, not string type.
" "c means “Use this space as a char, not as string” in .NET grammer.
(This c is capital of “char”)

As the another case, in UiPath, I often use “D” for define Decimal Type.
For example, 1.01D means “this value defines as Decimal type, not Double type”.
(To explain difference between Decimal and Double is hard work, you can understand “Double is faster at caliculating, Decimal is slower but more accurate in decimal system”.)

43 Likes

Thank you Honoka!

Please Suggest Any solution bellow scenario

1 Like

Thank you

@vaibhavkukreja

Here ‘c’ is the Character because of your splitting single character (space).
This C how it’s work:

  1. it will convert a given string into a character.
    instead of using that technique you can also try this way also myString.split(CChar(" ")).

Thanks,
Arunachalam

8 Likes

As what I have understood from the comments, the argument needed for split method needs to in Char Type not String Type. Since " " is String and not char adding c like, (" "c) after it, converts it to Character. Am I right?

2 Likes

A good resource for stuff like this is the .NET Framework Library.

https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualbasic.strings.split?view=netframework-4.8#Microsoft_VisualBasic_Strings_Split_System_String_System_String_System_Int32_Microsoft_VisualBasic_CompareMethod_

3 Likes

When Option Strict is On in VB (and it always is in UiPath), you need to specify when a Char is literal, as explained here:

There is more than one way to meet that requirement though. Ex.:

myString.Split(" "c)
myString.Split(convert.ToChar(" "))
myString.Split(Char.Parse(" "))
2 Likes

By using" "c means space as character if we r using "|"c means what

1 Like

In case we need to select the name of the file without extention, we use expression file.Name.Split(".“c)(0).
For example the file name is: “FileExample.pdf”
In this case:
file.Name.Split(”.“c)(0) == “FileExample”
file.Name.Split(”."c)(1) == “pdf”

P.S: I tried forum. :wink:

10 Likes

@imandric_11 , that means that the pipe | character will be used as a delimiter to split the string. I hope this helps.

It’s not possible to split without any common seperator.You have to use another logic if you’ve finite number of data.

C for “Character”