(TextValue as nullable text) =>
let
// If TextValue is null, replace it with an empty string
SafeText = if TextValue = null then "" else TextValue,
// List of replacement pairs (accents and digits)
AccentsList =
{
{null, "."},
{"à","a"},{"á","a"},{"â","a"},{"ã","a"},{"ä","a"},
{"è","e"},{"é","e"},{"ê","e"},{"ë","e"},
{"ì","i"},{"í","i"},{"î","i"},{"ï","i"},
{"ò","o"},{"ó","o"},{"ô","o"},{"õ","o"},{"ö","o"},
{"ù","u"},{"ú","u"},{"û","u"},{"ü","u"},
{"À","A"},{"Á","A"},{"Â","A"},{"Ã","A"},{"Ä","A"},
{"È","E"},{"É","E"},{"Ê","E"},{"Ë","E"},
{"Ì","I"},{"Í","I"},{"Î","I"},
{"Ò","O"},{"Ó","O"},{"Ô","O"},{"Õ","O"},{"Ö","O"},
{"Ù","U"},{"Ú","U"},{"Û","U"},{"Ü","U"},
{"ç","c"},{"Ç","C"},{"ñ","n"},{"Ñ","N"},
{"0",""},{"1",""},{"2",""},{"3",""},{"4",""},
{"5",""},{"6",""},{"7",""},{"8",""},{"9",""}
},
// Convert the text into a list of characters, removing any null entries
TextCharacters = List.RemoveNulls(Text.ToList(SafeText)),
// Replace characters according to AccentsList and then combine back into a single string
CleanedText = Text.Combine(List.ReplaceMatchingItems(TextCharacters, AccentsList), "")
in
CleanedText
No comments:
Post a Comment