I have some string like 11122_11255_12_223_12 and the output I wish to have is this: 12_125_12_23_12 I already looked at this and also this a
11122_11255_12_223_12
12_125_12_23_12
You can use capture group and back-reference:
result = str.replace(/(.)\1+/g, '$1')
RegEx Demo
(.)
\1+