Index was outside the bounds of the array 123

Hi i have same problem but,
There is a text I’m splitting it when it has 2 index’s but, sometime only 1 index is available then it throws Index was outside the bounds of the array.

for Example strExample=“Hospital Name 1-203659045”

I need to Split this and update into different columns
Please help me when it doesn’t have phone number need to ignore the phone number column

Hi,

Basic approach is to check count of array items. If it’s 1, please skip 2nd item or assign other value like empty string.
Or we can use regex to have each value. If it doesn’t match any string, returns empty.

Regards,

1 Like

@Krupa_P1

You can use a If Condition and write as below

strExample <> “”

Then split Else not split

Hope this may help you

Thanks

Hi @Krupa_P1,

Please try with For Each loop ‘Index’ to handle your scenario as in the inline screenshot. This sample I did for store multiple phone numbers. Same thing you can apply for your case.

Ex:
If loop index is 0 assigning first element in the loop to respective variable(ex:Name)
If loop index is 1 assigning second element in the loop to respective variable(ex:PhoneNumber)

Hope this will help you. Thank you.