Remove Accents from Names in a Datatable so that they will match in a comparison

Hi
I have a process that matches up names from 2 datatables and reports matches back to a user. I came across an issue today where a match should have been found but was excluded because the name in one of the datatables contains accents.

Made up example:
DT1
Gülçin Ekmekçi

DT2
Gulcin Ekmekci

Is there a way that I can get these names to match, maybe ignoring the accents or would i have to go through the datatable and replace them with non accented characters?

I have tried a for each loop using the solution on this FORUM POST but i think this would be slow running over a whole datatable and also i could not make it work.

Is there a way that I can replace all accented characters in a datatable without impacting performance too much?

Any help is much appreciated. Thanks

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.Replace(str1.Normalize(System.Text.NormalizationForm.FormD),"\p{Mn}","")

And we can use InvokeCode activity if there is performance issue.

dt.AsEnumerable.ToList.ForEach(Sub(r)
    r("ColumnName") = System.Text.RegularExpressions.Regex.Replace(r("ColumnName").ToString.Normalize(System.Text.NormalizationForm.FormD),"\p{Mn}","")
End Sub
)

Regards,

2 Likes

Thank You Yoichi!!! This both solutions worked perfectly, I’ll be making use of the solution using Invoke Code so that it will remove accents from all names in the datatable. Thank for your help with this and for sharing your knowledge. Much appreciated!!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.