Replace function

Hello,
Am try to split the value
Input -->test - 123456__123456_11_text file
am try to remove the six digit number (123456) and (__)
Output will be -->test -123456_11_text file

Thanks in Advance.
Anitha Anandhan.

hey @Anitha_Anandhan
you can use:
outputString = inputString.Replace("123456__", "").Replace("__", "_")

or Regex expression:

outputString = System.Text.RegularExpressions.Regex.Replace(inputString, "\d{6}__", "")
outputString = System.Text.RegularExpressions.Regex.Replace(outputString, "__", "_")

Hi @Anitha_Anandhan ,

Could also check with the below Expression :

System.Text.RegularExpressions.Regex.Replace(str,"__\d{6}","")

image

1 Like

Hi @Anitha_Anandhan

You can use the replace function with regular expression to remove specific data from Input. Check the below expression.

- Assign -> inputString = "test - 123456__123456_11_text file"

- Assign -> outputString = System.Text.RegularExpressions.Regex.Replace(inputString.ToString,"__\d{6}","")

Check the below workflow for better understanding,

Hope it helps!!

Hey Anitha,

You can use output = input.Substring(7) which would trim the first 7 letters of your string and you can also change the number according to your requirement

Hi @Anitha_Anandhan

str: test - 112233__123456_11_text

System.Text.RegularExpressions.Regex.Replace(str,"__\d{6}","")

Output: test - 112233_11_text

System.Text.RegularExpressions.Regex.Replace(str,"\d{6}__","")

Output: test - 123456_11_text

Hope it will helps you :slight_smile:
Cheers!!

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