I've searched but I can't find what I need, although I find solutions to replace but I can't find a solution that helps me.
I have an input string with accents and I need to remove the accents, my code:
string palabra = "pálábrá cón tíldés";
string palabaSinTilde = Regex.Replace(palabra, @"[^0-9A-Za-z]", "",
RegexOptions.None);
The output I have is:"plbr cn tlds"
What I need: word with accents
Thank you, have a good evening.
Try the following extension method
Explanation:
Characters like
á
,ö
, etc can be expressed in Unicode in two ways: A single character that corresponds to the character already accented :á
for example or two consecutive characters where the first character is the tilde and the next character is to be applied to´a
. Both ways result for text editors to show this version ->á
This line:
Ensures that the string is expanded to separate characters such as tides and other modifiers into their constituent characters.
Later
It makes sure to keep only those characters that are not diacritics.
Then a new string is created with characters already removed
Finally the chain is returned to its normal state with this line
I already solved my problem, First find out the format of my file, in this case it was UTF8, and with that data I found the solution:
using System.Text.RegularExpressions;
Honestly with this I solved it:
and the variable named palabaSinTildes looks like this: aeioun
Something like that
I think this is what you are looking for:
//Result is name