Java Utililty Methods String Slugify

List of utility methods to do String Slugify

  1. HOME
  2. Java
  3. S
  4. String Slugify

Description

The list of methods to do String Slugify are organized into topic(s).

Method

String slugify(final String s)
slugify
final String intermediateResult = Normalizer.normalize(s, Normalizer.Form.NFD)
 .replaceAll("[^\\p{ASCII}]", "").replaceAll("[^-_a-zA-Z0-9]", "-").replaceAll("\\s+", "-")
 .replaceAll("[-]+", "-").replaceAll("^-", "").replaceAll("-$", "").toLowerCase();
return intermediateResult.substring(0, Math.min(MAX_SLUG_LENGTH, intermediateResult.length()));
String slugify(final String s)
slugify
return Normalizer.normalize(s, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "")
 .replaceAll("[^\\w+]", "-").replaceAll("\\s+", "-").replaceAll("[-]+", "-").replaceAll("^-", "")
 .replaceAll("-$", "").toLowerCase();
String slugify(String input)
slugify
if (input == null)
 return "";
String nowhitespace = WHITESPACE.matcher(input).replaceAll("-");
String normalized = Normalizer.normalize(nowhitespace, Form.NFD);
String slug = NONLATIN.matcher(normalized).replaceAll("");
return slug.toLowerCase(Locale.ENGLISH).replaceAll("--+", "-");
String slugify(String input)
Converts the string into a string containing only hyphens, lower-case letters, and numbers, removing all other characters.
String nowhitespace = WHITESPACE.matcher(input).replaceAll("-");
String normalized = Normalizer.normalize(nowhitespace, Normalizer.Form.NFD);
String slug = MULTIHYPHENS.matcher(NONLATIN.matcher(normalized).replaceAll("-")).replaceAll("-");
return slug.toLowerCase(Locale.ENGLISH);
String slugify(String s)
slugify
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();
return result;
...
String toSlug(final String input)
Convert the String input to a slug.
if (input == null) {
 throw new IllegalArgumentException("Input cannot be null");
final Pattern NONLATIN = Pattern.compile("[^\\w-]");
final Pattern WHITESPACE = Pattern.compile("[\\s]");
String nowhitespace = WHITESPACE.matcher(input).replaceAll("-");
String normalized = Normalizer.normalize(nowhitespace, Form.NFD);
String slug = NONLATIN.matcher(normalized).replaceAll("");
...
String toSlug(String input)
http://stackoverflow.com/questions/1657193/
String nowhitespace = WHITESPACE.matcher(input).replaceAll("-");
String normalized = Normalizer.normalize(nowhitespace, Form.NFD);
String slug = NONLATIN.matcher(normalized).replaceAll("");
return slug.toLowerCase(Locale.ENGLISH);
String toSlug(String input)
Convert the String input to a slug.
if (input == null) {
 throw new IllegalArgumentException("Input cannot be null");
String nowhitespace = WHITESPACE.matcher(input).replaceAll("-");
String normalized = Normalizer.normalize(nowhitespace, Form.NFD);
String slug = NONLATIN.matcher(normalized).replaceAll("");
return slug.toLowerCase(Locale.ENGLISH);
String toSlug(String s)
to Slug
s = Normalizer.normalize(s, Normalizer.Form.NFD);
s = s.replaceAll("\\.", "-");
s = s.replaceAll(":", "-");
s = s.replaceAll("\\s+", "-");
s = s.replaceAll("[^\\p{ASCII}]", "");
s = s.replaceAll("[^a-zA-Z0-9- ]", "");
s = s.toLowerCase();
s = s.replaceAll("--", "-");
...


AltStyle によって変換されたページ (->オリジナル) /