So I am extracting some data from a some websites and would like to remove some unnecessarily text from it.
So I did some parsers that can control the parsed content before presenting it to the users.
Here is my test code that I did.
// tried using this but it strill did not work
function escapeRegex(string) {
return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
var div = document.getElementById("content");
var txArray = ["If you find any errors ( broken links, non-standard content, etc.. ), Please let us know < report chapter > so we can fix it as soon as possible.", "KobatoChanDaiSuki"]
txArray.forEach(x => {
var reg = new RegExp(escapeRegex(x), "gi");
div.innerHTML = div.innerHTML.replace(reg, "");
});
<div id="content">
Hyung : Big/older brother. Kind of an equivalent to the japanese “onii-san” but only used between male (male to male).
Translator :Pumba
TL Check : KobatoChanDaiSuki
If you find any errors ( broken links, non-standard content, etc.. ), Please let us know < report chapter > so we can fix it as soon as possible.
</div>
Se above it is not removing all the contents, Why is that ?
maybe I need to break the long string and then try to clean it, I really do not know? What do you think?