Regex to remove the extra character

If any of these format matches
*INV23456-DA
INV2334646SWL
INV01234567
5678901
23456-A2334
&23455
8789-UK345
INV;56778
INV-23478
4566%25
Then remove the characters as expected in output and returns boolean true if not need boolean as false
O/P
INV23456
INV2334646
INV01234567
5678901
23456
23455
8789
INV56778
INV23478
4566

Hi @Demo_User

Use the below regex expressions to remove the special characters,/

image

Hope it helps!!

Hi @Demo_User ,

Maybe you could also try with the below expression :

String.Join(Environment.NewLine,Regex.Split(variable1,"\r?\n").Select(Function(x)Regex.Replace(x,"\W","")))

Visual :
image

Try this,

([A-Z]+[0-9]+)?([0-9])+

Cheers,

1 Like

@Demo_User ,

A shorter version :

Regex.Replace(variable1,"[^0-9A-Za-z\r\n]","")

Visual :
image

Please check my output i want those as my output not only to remove special character
Special character +Extra character

For these combinations these as output

@Demo_User ,

Could you let us know if there are other varying formats that you might get ?

We currently see that there is a separate condition for INV related data and separate condition for Numbers.

So is that the case throughout ? Or do we have many more conditions or other formats other than the provided ?

INV ans Number
These are the combinations and formats
Speical characters would be varying that would be any special character
But combination will be these
.
First thing if anything within this format set the match true
And then remove the characters
Or not need set boolean match is false

try as per below file

note - i have use write line activity to get out put , in that place you can replace as required

assuming most possible cases as per your input and output

ListFormatString.xaml (11.6 KB)

Hope this helps

@Demo_User ,

Maybe you could also try with the below approach :

  1. Modify the Input String to remove the Special Characters at the beginning.
InputString = String.Join(Environment.NewLine, Regex.Split(InputString,"\r?\n").Select(Function(x)Regex.Replace(x,"^\W+","")))
  1. Next, we keep only the INV data upto end of the Number in it and data starting from Numbers upto the special character using the below expression :
OutputString = String.Join(Environment.NewLine,Regex.Matches(InputString,"(INV.*\d+)|^\d+",RegexOptions.Multiline).Select(Function(x)Regex.Replace(x.Value,"\W+","")))

Visual :
image

1 Like

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