I tried slugify and slug packages but strings like കവാടം പൊളിക്കണം: "ലോ അക്കാദമിക്കു" നോട്ടിസ് return a blank string instead of കവാടം-പൊളിക്കണം-ലോ-അക്കാദമിക്കു-നോട്ടിസ്. Words should be preserved, special characters should be stripped.
Is there a way to generate slugs that preserves arbitrary non-English words?
Regular expression to match non-English characters? seems the best resource for matching international words.
This following regEx match-replace worked fine for spaces only.
var s = 'കവാടം പൊളിക്കണം: "ലോ അക്കാദമിക്കു" നോട്ടിസ്';
var res = s.replace(/ /g,"-");
console.log( res );
For all special characters you can use following.
var s = 'കവാടം പൊളിക്കണം: "ലോ അക്കാദമിക്കു" നോട്ടിസ്';
// Keep symbols you want to replace with hyphen.
var res = s.replace(/[&\/\\#,+()$~%.'":*?<>{} ]/g,"-");
console.log( res );
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