Remove Duplicate

Remove Duplicate
Input value: 225336675992
Need Output: 25367592

welcome to the forum

we can do with regex.replace

Thank you for your reply on this, Could you please suggest anyother method to remove duplicates and get output value.

like LINQ method or For Each/If Condition. If anyone


Updated for handling also more then 2 following same digits:

With Regex we can do it very compact compared e.g. LINQ or for each

A for each would run over all characters and will memorize the n-1 char
A same char in sequence is detected when n-1 char = n char

n - the current loop

1 Like


Try this,

Assign a variable : input String =“225336675992”
Enumerable.Distinct(input String)