Replace diacritic (accented) characters

Managed by | Updated .

The following post process hook script takes a metadata field containing diacritic characters and produces a second normalised field with the accented characters replaced with non-accented versions.

Useful if you need to strip the characters - eg. on query completion triggers that might need to match the diacritics.

hook_post_process.groovy
import java.text.Normalizer;
import java.text.Normalizer.Form;
 
transaction?.response?.resultPacket?.results.each() {
 
// Created a normalised version of the name metadatafield that removes diacritics
    it.metaData["nameNormalized"] = Normalizer.normalize(it.metaData["name"], Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
Was this artcle helpful?

Tags
Type: Keywords:
Features:
XML
Frontend > Hook scripts

Comments