How to remove character from string

Hey Hello, Guys

I want to remove the character from the string.
E.g.

  1. ILD123456
  2. ILD654321

OutPut Should like below

  1. 123456
    2.012345
    Only integer value should remain, no character value from start.
    Or if wanted to replace those “ILD” with “” (nothing)?

I am extracting multiple strings like this wanted to do for every

Thanks.

give a try on regex
grafik

for a replace we can use following pattern for the opposite:
grafik

Hi there @Bot_Learner,
I hope you are well!

You should be able to achieve this via the below:
Assign - YourString = New String(YourString.AsEnumerable().Where(Function (character) Char.IsDigit(character)).ToArray)

This will remove any non-numeric values.
With that said, it will throw an exception if none exist, so it may be worth using:
If - YourString.AsEnumerable().Any(Function (character) Char.IsDigit(character))
Then
Assign - YourString = New String(YourString.AsEnumerable().Where(Function (character) Char.IsDigit(character)).ToArray)
Else
Assign - YourString = String.Empty

Please let me know if you have any questions.
Thanks once again for your support,
Josh

1 Like

@ppr thanks for the reply,
If i have same value(ILD123456) in a variable like “ILDFromWeb” and wanted to replace the “char” value
how to write that
Regex.Replace(ILDFromWeb,"\D+") ?

Regex.Replace(ILDFromWeb,"\D+",String.Empty)

in case more numbers are wtihin the string:

Regex.Replace(ILDFromWeb,"\D+"," ")

For more Regex Api Samples have a look here:
[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum