Replace value in string

Hi,

I have a string value of “27726546122”
I need to replace the first 2 numbers with a zero
how would i assign the variable?

thanks

@Ziyaad_Conrad1

Welcome back to our UiPath community.

         Input = "27726546122"
         Output = Input.Replace(Input.SubString(0,2),"0")
1 Like

Hi thanks ,

I tried but it only replaces the first number

image

Hope this helps…

give a try on “00” & YourString.SubString(2)
grafik

1 Like

@Ziyaad_Conrad1

I updated the expression. Can you try now.

1 Like

Simpler just to use the right function then add the 0 on the front.

myStr = “27726546122”
newStr = “0” + Right(myStr,myStr.Len - 2)

1 Like

Hi @Ziyaad_Conrad1

Try with regex and replace

Assign a string variable

System.Text.RegularExpressions.Regex.Replace("27726546122","^\d{2}","00")

image

Hope it Helps

Regards
Sudharsan

1 Like

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