Question: I'm trying to clean strings which has been transformed from word text but I'm stuck on removing special character '…'

By click on button "clean", script removes all dots and only one special character, however I need to remove all of them

Where is my mistake? 

Here is my code and [plunker](https://plnkr.co/edit/7XpkMM6VKEYqgr2L6j5z?p=preview) with struggles 

```
    $scope.string = "My transformed string &hellip;&hellip;&hellip;&hellip;.........&hellip;...."

 $scope.removeDots = function () {
        var em = document.getElementsByTagName('em');
        var reg = /\./g;
        var hellip = /&hellip;/g

        angular.forEach(em, function (item) {

            if(item.innerText.match(reg)){
                 item.innerText = process(item.innerText)
            } 
            if (item.innerText.match(hellip)){
              item.innerText = item.innerText.replace("&hellip;", "")
            }
        });
    };

    function process( str ) {
        return str.replace( /^([^.]*\.)(.*)$/, function ( a, b, c ) {
            return b + c.replace( /\./g, '' );
        });
    }

```

Answer: 
There's a few problems here, but they can all be resolved by simply reducing the code to a single regex replace within `process` that will handle both periods and `&hellip;` entities:

```
 $scope.removeDots = function () {
        var em = document.getElementsByTagName('em');
        angular.forEach(em, function (item) {
              item.innerText = process(item.innerText)
        });
    };

    function process( str ) {
        return str.replace( /\.|&hellip;/g, '');
    }
});

```

[Plunker demo](https://plnkr.co/edit/CyRiO19TnojazXu1od0V?p=preview)
You can do both replacements by first replacing the occurrences of `&hellip;` with one point (because it might be the only thing you find), and then replacing any sequence of points by one:

```js
function process( str ) {
    return str.replace(/&hellip;/g, '.').replace(/\.\.+/g, '.');
}

var test="My transformed string &hellip;&hellip;&hellip;&hellip;.........&hellip;....";

console.log(process(test));
```

One of the reasons your code did not replace everything, is that you used a string as *find* argument, which will result in one replacement only. By using the regular expression as *find* argument you can get the effect of the `g` modifier.