private final String slug(final String text) {
        final String separator; // Separator for swapping whitespaces
        String corrected;       // Modified string

        checkNotNull(text, "Received a null pointer as the text");

        separator = "-";

        corrected = text.replace('/', '-').replace('\\', '-').replace('.', '-')
                .replace('_', '-');

        // Removes multiple lines
        corrected = getMultipleHyphenPattern().matcher(corrected)
                .replaceAll(separator);
        // Removes white spaces
        corrected = getWhitespacePattern().matcher(corrected)
                .replaceAll(separator);
        // Removes non-latin characters
        corrected = getNonLatinPattern().matcher(corrected).replaceAll("");

        return corrected.toLowerCase();
    }
private final String slug ( final String text ) { final String separator ; String corrected ; checkNotNull ( text , "Received a null pointer as the text" ) ; separator = "-" ; corrected = text . replace ( '/' , '-' ) . replace ( '\\' , '-' ) . replace ( '.' , '-' ) . replace ( '_' , '-' ) ; corrected = getMultipleHyphenPattern ( ) . matcher ( corrected ) . replaceAll ( separator ) ; corrected = getWhitespacePattern ( ) . matcher ( corrected ) . replaceAll ( separator ) ; corrected = getNonLatinPattern ( ) . matcher ( corrected ) . replaceAll ( "" ) ; return corrected . toLowerCase ( ) ; }
Returns a URL slug created from the received text.
<p>
A slug is a human-readable version of the text, where all the special
characters have been removed, and spaces have been swapped by dashes.
<p>
For example: <em>This, That & the Other! Various Outré
Considerations</em> would become
<em>this-that-the-other-various-outre-considerations</em>
<p>
Of course, this can be applied to any text, not just URLs, but it is
usually used in the context of an URL.

@param text
text to generate the slug from
@return the slug of the given text