EDIT: Not a duplicate, I've already tried the possible solutions at:
How to replace all dots in a string using JavaScript
I've having a JS issue with string.replace not replacing periods/ellipsis, maybe I'm just really tired but it's annoying the **** out of me. I'd appreciate any suggestions. This is in a chrome extension content script if that has any relevance.
I've tried variations of the below code and .split, other regex, etc. with no luck. All content of document.body.innerText.toLowerCase().trim().split(/\s+/); is from the Google homepage after searching for the keyword "google".
Relevant code:
var kwArr = document.body.innerText.toLowerCase().trim().split(/\s+/);
//stupid period/ellipsis...
//begin loop(i)
kwArr[i] = $.trim(kwArr[i].replace(/\.+$/g, ''));
kwArr[i] = kwArr[i].replace('.', '');
kwArr[i] = kwArr[i].replace("\./g", "");
kwArr[i] = kwArr[i].replace('/\./g', '');
kwArr[i] = kwArr[i].replace('/\u2E7F\/g', '');
kwArr[i] = kwArr[i].replace('/\u2E7F\/g', '');
//end loop(i)
//end hacks
Array dump with frequency after running kwArr through replace, etc.:
Any help would be greatly appreciated, thanks!
EDIT: Data from console.log(JSON.stringify(kwArr)):
https://gist.github.com/PlexXoniC/5084ff5fb69785f60bd043a205923601