I have a string like (- ABCDE-15-826-79- - - - - - -) . I want to add B after 9 in this string . This string is not constant , but I always wanted to add B before the last set of hyphens starts

I have a string like (- ABCDE-15-826-79- - - - - - -) . I want to add B after 9 in this string . This string is not constant , but I always wanted to add B before the last set of hyphens starts .

So it’s always like the last letter should be B before continuous set of hyphens start. How to do it ?

Hi @Ragavi_Rajasekar ,

Thanks for reaching out UiPath Community.

Can you try applying regex where you first get a set of hyphens and then add B before that and Merge both the strings?

Hope it works for you.

Happy Automation,
@Vinit_Kawle

Hi @Ragavi_Rajasekar

Use the below in assign activities

Input = "(- ABCDE-15-826-79- - - - - - -)"
Output = Input.Insert(System.Text.RegularExpressions.Regex.Match(Input,"(.*[A-Za-z]*\-[\s\S].*\d+)").Value.Length,"B")

I have attached an xaml please check it for better understanding.

Main.xaml (10.9 KB)

Hope it works!!

Regards

Thank you so much … it worked

1 Like

Hi @Ragavi_Rajasekar

You’re Welcome.

Happy Automation !!

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