How to use Unicode numeric values in regexprep?
이전 댓글 표시
How can "Häagen-Dasz" be converted to "Haagen-Dasz" using Uincode numeric values? For example,
regexprep('Häagen-Dasz','ä','A')
works fine, but
regexprep('Häagen-Dasz','\x{C4}','a')
does not. Here, the hexadecimal \x{C4} stands for [latin capital letter a] with diaeresis, i.e. [ä].
댓글 수: 1
VBBV
2024년 3월 28일
I am not sure if i understand your question right, but Read this answer below
채택된 답변
추가 답변 (2개)
inp = 'Häagen-Dasz';
baz = @(v)char(v(1)); % only need the first decomposed character.
out = arrayfun(@(c)baz(py.unicodedata.normalize('NFKD',c)),inp) % remove diacritics.
Read more:
https://docs.python.org/3/library/unicodedata.html
https://stackoverflow.com/questions/16467479/normalizing-unicode
regexprep('Häagen-Dasz','ä','A')
regexprep('Häagen-Dasz','ä','\x{C4}')
댓글 수: 2
regexprep('Häagen-Dasz','\x{e4}','a')
VBBV
2024년 3월 28일
The unicode character for small a is \x{e4}
카테고리
도움말 센터 및 File Exchange에서 App Building에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!