Java String Slugify slugify(final String s)

Here you can find the source of slugify(final String s)

Description

slugify

License

Apache License

Declaration

public static String slugify(final String s) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.Normalizer;

public class Main {
    public static String slugify(final String s) {
        //algorithm used in https://github.com/slugify/slugify/blob/master/core/src/main/java/com/github/slugify/Slugify.java
        return Normalizer.normalize(s, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "")
                .replaceAll("[^\\w+]", "-").replaceAll("\\s+", "-").replaceAll("[-]+", "-").replaceAll("^-", "")
                .replaceAll("-$", "").toLowerCase();
    }//from  w  w  w  . j  a  v  a 2 s.co m
}

Related

  1. slugify(final String s)
  2. slugify(String input)
  3. slugify(String input)
  4. slugify(String s)
  5. toSlug(final String input)