Split String Issues

I am trying to split a string(defined as Generic Type) P 12345 as P and 12345

I have first converted it into String. Next, I have used the Split function as :
Split(ManagerDetails.tostring,“P”)

Using for loop, I am trying to capture each of the elements. But the output is not as expected. It appears to be System.String and System.String

Can someone provide the solution for this?

P.S I have tried using the Split Activity under expressions. The output remains the same.

Hey @nesachdeva

please review the attached sample workflow and let me know.

here you should split on the basis of space.

str.Split({" "c}, StringSplitOptions.RemoveEmptyEntries)

splitstring.xaml (7.0 KB)

Regards…!!
Aksh

That worked! Thanks!

Can you help me out on saving the output 12345 into a variable?

Hi @nesachdeva

If you always gets the same string then just use if condition and compare the word and assign it into a new variable.

Regards…!!
Aksh

Nope, it changes every time.

In that case you just let me know the string count you will always? get same? and the first character will be “P” or different.

So i am assuming if the string count will be same then based on count you can fire the if condition and assign the word into some variable.

Hope it will be useful for you…!!

Regards…!!
Aksh

1 Like

the string count is 11.
P 12345678

i was asking about after space but based on assumption you can do this.

Hope this will be useful for you.

Regards…!!
Aksh

1 Like

That looks fine.
Sorry, i missed about the spaces, there are two spaces between P and the digits.

Thanks for the prompt help!! :slight_smile:

Hi

can u help me how to split variable from pdf

Hi @aksh1yadav ,
Can you tell me that “c” from str.Split({" "c} stands for what? I understand that the split will be made between spaces but don’t see the point of the c

(I’ve seen this c several times but no idea what it is used for)

Thank you and regards,
Jules

It’s there to declare the " " as a Char instead of String.
In C# you’d do it like this:
char aChar = ' ';
But in VB.Net apostrophe (or single quotes) ' are used as comments, so you can’t do it. And quotes are for strings. So instead of adding another special char, you just indicate it with c after a 1-char length string:
Dim aChar as Char = " "c

See here for more on MSDN.

2 Likes

what does the c mean here

Hi @PrankurJoshi,

here c ->Character

Regards,
Arivu

1 Like