I am trying to transliterate ®, ©, ', and ™ into blank characters meaning completely removing them when they are slugified.
The following is what I tried to do:
var tr = require('transliteration');
var slugify = require('transliteration').slugify;
// replacement attempt
tr("0xAE, 0xFEFF"); // ®
tr("0xA9, 0xFEFF"); // ©
tr("0x2122, 0xFEFF"); // ™
slugify(name, { lowercase: true })
For example, when I use slugify on a name like "ABC®: 123", it transliterates to:
abc-r-123
However, I want the resulting name to be like:
abc-123
See following steps, how I did it:
console.log(tr("ABC ©")); //Output: ABC (c)
var test1 = "ABC®: 123©" //test input to see results
var regex = /\((r)\)|\((c)\)/g; //regex to remove ® and ©, update on desire
console.log(tr(test1).replace(regex,'')); //Output: ABC: 123
//now sluggify
console.log(slugify(test1, { lowercase: true, separator: '-' })); //Output: abc-123
Further working can be seen on Github Here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With