Java String Slugify slugify(String s)

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

Description

slugify

License

Apache License

Declaration

public static final String slugify(String s) 

Method Source Code


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

import java.io.File;

import java.text.Normalizer;
import java.util.Collection;
import java.util.Map;

public class Main {
    public static final String slugify(String s) {
        if (s == null)
            return null;

        if (s.isEmpty())
            return s;

        String result = Normalizer.normalize(s, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "");
        result = result.replace(" ", "-");
        result = result.toLowerCase();//  w w w.jav a 2  s  .co m

        return result;
    }

    public static boolean isEmpty(Collection o) {
        return o == null || o.isEmpty();
    }

    public static final boolean isEmpty(String o) {
        return o == null || o.length() < 1;
    }

    public static final boolean isEmpty(File o) {
        return o == null || !o.exists() || o.length() < 1L;
    }

    public static final boolean isEmpty(Object[] o) {
        return o == null || o.length < 1;
    }

    @SuppressWarnings("unchecked")
    public static final boolean isEmpty(Map o) {
        return o == null || o.isEmpty();
    }

    public static final boolean isEmpty(Object o) {
        return o == null;
    }
}

Related

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