Java code/library for generating slugs (for use in pretty URLs)
问题 Web frameworks such as Rails and Django has built-in support for "slugs" which are used to generate readable and SEO-friendly URLs: Slugs in Rails Slugs in Django A slug string typically contains only of the characters a-z , 0-9 and - and can hence be written without URL-escaping (think "foo%20bar"). I'm looking for a Java slug function that given any valid Unicode string will return a slug representation ( a-z , 0-9 and - ). A trivial slug function would be something along the lines of: