Holiday Slugifier

String Manipulation Slug Holiday New Year Coding

Problem Description

On December 30, as we eagerly await New Year celebrations, event organizers need to quickly generate URL-friendly slugs from event names. A slug is a simplified version of a string that is lowercase, punctuation-free, and uses hyphens to separate words.

Write a function that takes an input string and returns its slug following these rules:

  • Convert the entire string to lowercase.
  • Remove all punctuation (e.g., !, ., ?, ',', etc.).
  • Replace spaces and underscores with hyphens.
  • Replace multiple consecutive hyphens with a single hyphen.
  • Remove any leading or trailing hyphens.

You can assume the input string is non-empty.

Examples

Input: "New Year's Bash 2024!"

Output: "new-years-bash-2024"

Input: " Welcome_to_The New Year Gala!!! "

Output: "welcome-to-the-new-year-gala"

Write your solution in any programming language of your choice.