I want to replace my string by single charter if any string is continuously coming.

Say for example, I have string format like this.

```
 string str="eeexampple"

```

I need to replace all the repeated charters by single character. So my expected output will be something like this.

```
  "example"

```

how can I achieve this?