All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.softicar.platform.common.string.normalizer.DiacriticNormalizer Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
package com.softicar.platform.common.string.normalizer;

import java.text.Normalizer;
import java.util.regex.Pattern;

/**
 * Removes diacritics (aka. diacritical marks) from text.
 *
 * @author Alexander Schmidt
 */
public class DiacriticNormalizer {

	private static final Pattern ACCENTS_PATTERN = Pattern.compile("\\p{M}");

	/**
	 * Removes diacritics from the characters in the given text.
	 * 

* Relies on Unicode decomposition mappings. * * @param text * the text to strip of diacritical marks (never null) * @return the given text, stripped of diacritical marks (never null) */ public String normalize(String text) { return ACCENTS_PATTERN// .matcher(Normalizer.normalize(text, Normalizer.Form.NFKD)) .replaceAll(""); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy