Skip to content

Instantly share code, notes, and snippets.

@justsml
Created April 21, 2020 01:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justsml/1db647a3b00b65c04536219501e08f7b to your computer and use it in GitHub Desktop.
Save justsml/1db647a3b00b65c04536219501e08f7b to your computer and use it in GitHub Desktop.
const combiningMarks = /([\0-\u02FF\u0370-\u1AAF\u1B00-\u1DBF\u1E00-\u20CF\u2100-\uD7FF\uE000-\uFE1F\uFE30-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])([\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]+)/gmi;
/**
Remove unicode combining symbols.
Will convert the following string: Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍͔̹̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘!͖̬̰̙̗̿̋ͥͥ̂ͣ̐́́͜͞
Into: ZALGǪ!
*/
export const removeCombiningMarks = (input) => {
return input.replace(combiningMarks, (substr, ...args) => {
// console.log(args);
return args[0]
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment