public static String toSlug(String pathPiece){
        String s = pathPiece.replaceAll("\\s+", "-").toLowerCase();
        s = s.replaceAll("[^\\w-_/]", "");
        return s;
    }
public static String toSlug ( String pathPiece ) { String s = pathPiece . replaceAll ( "\\s+" , "-" ) . toLowerCase ( ) ; s = s . replaceAll ( "[^\\w-_/]" , "" ) ; return s ; }
Converts a String to a URL-safe, or 'slug' version. This converts the input to lowercase and replaces all
characters with dashes (-) except for alphaneumerics, dashes (-), underscores (_), and forward slashes (/).

@param pathPiece the input to 'slugify'
@return the URL-safe slug