Removing emoji from string with Javascript

I'm using the "Transform & Replace Selection with Javascript" action, but I can't seem to get the replaceAll function working. This is what I have:

async (clipboardContentString) => {
   return clipboardContentString.replaceAll("[^\\p{L}\\p{M}\\p{N}\\p{P}\\p{Z}\\p{Cf}\\p{Cs}\\s]", "");
}

And here is some sample input:

fall-:sweat_smile:forwa​:innocent:rd öäü how to do in java . com A função, Ãugent

Test execute just returns the same string, but I want to remove emoji and characters such as ã.

Any ideas?

This seems to work:

async (clipboardContentString) => {
return clipboardContentString.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g, '');


}
1 Like

That worked perfectly. :slight_smile: Thanks so much.