Need help to replace first letter of a string with another letter

Hi,

I have a requirement that when the string starts with 1, I need to replace first letter 1 with Alphabet ‘I’. Can anyone help me with replacing only first letter with another letter. Thanks!

Input - 111IF

Output should be - I11IF

Regards,
Divya.

Hey

can you give a try with the following?

strInput.Substring(0,1).Replace("1","I") + strInput.Remove(0,1)

Regards

str_variable = “111IF”

str_variable = If(str_Sample.StartsWith(“1”),str_Sample.Replace(str_Sample(0),“I”),“”)

Pls mark it as solution if it resolves your issue.

2 Likes

Hi @divya.x.kuchi

How about this Regex expression ?

System.Text.RegularExpressions.Regex.Replace(YourInputString,"^\d","I").Tostring

image

Regards
Gokul

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