How to split excel value string

Hi All, i struct in splitting a string can anyone suggest me how to split a string.

Input EX: 1) CNP-46TAC9 2020-01-POC-RC6
2) 2021-KC-MNC-Pro

Output: CNP
46TAC9
2020
01
POC
RC6

Output 2: 2021
KC
MNC
Pro

1 Like

Hi @Learner007

Use the below expression to split!

InputString.Split("-"c)

And Use For each to iterate the string values

Regards

2 Likes

Hi @Learner007 ,

Since we are getting different combinations first we have to replace the blank space with the keyword - like below.

Yourstring.replace(" “,”-")

Now please follow the suggestion by @pravin_calvin .

Yourstring.split("-“c)(0) → to get the first one.
Yourstring.split(”-"c)(1) → to get the second one so on.

or you could use string arry to capture all the entries like below.

strarr = Yourstring.split("-"c)

and use for each loop to get all the splitted strings one by one. thanks.

Hi @Learner007 !
Welcome to UiPath Community :grinning_face_with_smiling_eyes:

Here is a suggestion: Split data.xaml (8.0 KB)

2 Likes

Hi @kirankumar.mahanthi1 some time i’m getting 2 or 3 spaces is there any way to replace at a time or i need to replace activity multiple times

try this:
yourString.Split(New String(){" “,”-"},StringSplitOptions.None)

Thanks
pravu.

1 Like

Replace activity replace all the blank spaces to key word at a time. No need to use multiple times or use some valuable suggestion given by the other members in this thread. Thanks.

Hi @Learner007

Can you please try the below code?

Code:
Main.xaml (6.4 KB)

Thank you.

hi @Jobin_Joy this is working for single space , some times i will get 2 or 3 spaces in between i want to replace them by (-) how can i replace multiple spaces into single value (-)

Hi @Learner007

Please use the below code for your requirement.

Updated Code:
Main (1).xaml (7.2 KB)

Hope this will be helpful. Thank you.

1 Like

Thanks @Jobin_Joy it’s working

1 Like

Glad to hear that it’s helped you. Thank you.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.