I have been working on cleaning strings that were transformed from word text, but I am facing an issue with removing the special character '…'
When I click on the "clean" button, the script currently removes all dots and only one special character. However, I actually need to remove all occurrences of this special character.
Can someone help me identify where my mistake is in my code?
Here is the code snippet:
$scope.string = "My transformed string ………….........…...."
$scope.removeDots = function() {
var em = document.getElementsByTagName('em');
var reg = /\./g;
var 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("…", "")
}
});
};
function process(str) {
return str.replace(/^([^.]*\.)(.*)$/, function(a, b, c) {
return b + c.replace(/\./g, '');
});
}
Here is the Plunker link with the struggles.