Hello I'm wondering how to filter out these custom Facebook symbols.
CULTURE CLUB PRESENTS JENNIFER CARDINI
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
We proudly presents JENNIFER CARDINI
Support by Monsieur Moustache & Thang
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
LINE-UP
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
#TOWNHALL
▮ Monsieur Moustache
▮ Thang
▮ JENNIFER CARDINI
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
JENNIFER CARDI ...
The expected result is the same text without the thick hyphens and music symbols.
I have very little knowledge about regex. I'm using this simple function but I think I need another replacement pattern.
function zonderRareSymbolen(str) {
new_string = str.replace(/^([ A-Za-z0-9_@#+-.'"]+(\r)?(\n)?)*$/g, '');
return new_string.toLowerCase();
}
Is it possible? I already tried litteraly putting pasting the symbols in the replace pattern. Can't I use a pattern that only allows letters and numbers?
UPDATE This function works if I literally put the text in:
zonderRareSymbolen('... Kisses ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Come ...');
function zonderRareSymbolen(str) {
new_string = str.replace(/▬/g, '');
return new_string;
}
But not on my detail.description
value from an object:
zonderRareSymbolen(String(detail.desciption));
function zonderRareSymbolen(str) {
new_string = str.replace(/▬/g, '');
return new_string;
}
Any ideas?
UPDATE The replace function doesn't seem to work with the custom symbol. All I can do now is work around it and only allow the desired characters like this:
function zonderRareSymbolen(str) {
return (str).replace(/[^a-zA-Z0-9- ,=?&:.'"@/]/g, ' ');
}
SOLVED By Mariano. After putting in <meta charset="UTF-8">
I am able to litterally paste the symbols into my replace function and replace them.