Assign: Specified argument was out of the range of valid values. (Parameter 'startIndex')

Hi Team , I am getting error while getting the output of policy number.
Assign: Specified argument was out of the range of valid values. (Parameter ‘startIndex’).

Policy No- 2491040808851, 249152651092 , some policy numbers are 12 digit and some are 13 digit and want to add (-) after 2 digit and before last digit also.

ex: (24-91-04080885-1), (24-91-5265109-2)

Hi @bshinde

Try this

If(String.IsNullOrEmpty(policyNumber) OrElse policyNumber.Length < 3, policyNumber, $"{policyNumber.Substring(0, 2)}-{policyNumber.Substring(2, 2)}-{policyNumber.Substring(4, 8)}-{policyNumber.Substring(policyNumber.Length - 1)}")

Regards,

Hi @bshinde

inputString: 2491040808851

Use expression or below output.
Output: 24-9104080885-1

inputString.Insert(2, “-”).Insert(inputString.Length, “-”)

AND

Use expression or below output.
Output: 24-91-04080885-1

inputString.Insert(2, “-”).Insert(5, “-”).Insert(inputString.Length, “-”)

Hope it will helps you :slight_smile:
Cheers!!

grafik

And also
grafik

[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum
Prototypes done within immediate panel
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

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