How to get first 11 values from a variable. It's urgent can anyone help me please

In a variable i have 12 names, now i want to extract only first 11 values from that variable. How can i do that, can anyone help me please.

hi @sandhyarani , is this a String Array that you need to print? In that case you can loop and print till your desired index value.

Hey @sandhyarani ,
What is the Type of your Varibale?
Is it array of Strings?

Regards,

Hi @sandhyarani ,

Welcome to the community.

You can use string manipulation
How to manipulate a part of string: Split, Trim, Substring, Replace, Remove, Left, Right - News / Tutorials - UiPath Community Forum

Hope this will help you.

Please dont forget to mark this thread as solution, if this helps you.

Regards

Hi @sandhyarani ,

Can you specify what is the type of variable?, and if the variable is a string, then how are each of the values separated?

Regards,

array of strings only. separated by ,

@sandhyarani ,

ArrayOfStringVariable.Take(11)

Regards,

1 Like

Hi @sandhyarani ,

Maybe an extension on @vishal.kp Post :

ArrayOfStringVariable.Take(11).ToArray

Also, If Required in String Format :

String.Join(",",ArrayOfStringVariable.Take(11).ToArray)

@sandhyarani

Can you share the sample string you have?

Thanks,
Srini

Number,Correlation display,Short description,Caller,Affected user,State,Assigned to,Updated,Updated by,Assignment group,Created,Resolved,

this is the string i have. I want only till Created one

@sandhyarani ,

If it is a String variable, then maybe a Split first and then perform the Take Operation :

Split(YourStringVar,",").Take(11).ToArray

Also, let us know if we need to go by the Condition based on value or by the number of values.

i am just getting like this Sytem.String

Number of values only.

@sandhyarani ,

Maybe you require it in the String format, do check the post before and use String.Join(",") for the conversion and check.

We would need to know what is the format you want the output to be stored or Represented.

@sandhyarani

Try as below

Hope this may help you

Thanks,
Srini

I should get the output, same like input format only.

@sandhyarani

Array1 = {“1”, “2”, “3”…}

Now declare another or the same Array variable

Now write as Array1 = Array1.Take(11).ToArray()

Hope this will help you

Thanks,
Srini

Here, i am getting an error like Array is a type cannot be used as an expression.

i am getting an error like cannot assign from system char to system string

@sandhyarani , if possible can you share a scheenshot of your workflow or the xaml file.

Regards,