Posts

remove all characters like - // and other characters by using slug this is a code with using function

 function slug(str) {

    return str
        .toLowerCase()               // Convert to lowercase
        .trim()                      // Remove leading and trailing spaces
        .replace(/[^\w\s-]/g, '')    // Remove all non-word characters
        .replace(/\s+/g, '-')        // Replace spaces with hyphens
        .replace(/--+/g, '-');       // Replace multiple hyphens with a single hyphen
}

let a = "   This is an example of slug / // ///"
console.log(slug(a));

Post a Comment

Tech Digital Welcome to WhatsApp chat
Howdy! How can we help you today?
Type here...