Split String Issues


#1

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.


#2

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


Split string
#3

That worked! Thanks!

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


#4

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


#5

Nope, it changes every time.


#6

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


#7

the string count is 11.
P 12345678


#8

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

Hope this will be useful for you.

Regards…!!
Aksh


#9

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:


#10

Hi

can u help me how to split variable from pdf


#11

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


#12

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.


#13

what does the c mean here


#14

Hi @prankurjoshi,

here c ->Character

Regards,
Arivu