gpt4 book ai didi

regex - 使用 r 删除希伯来语 "niqqud"

转载 作者:行者123 更新时间:2023-12-04 21:12:03 25 4
gpt4 key购买 nike

一直在努力删除niqqud (用于表示元音或区分希伯来字母表字母的替代发音的变音符号)。
例如,我有这个变量:
sample1 <- "הֻסְמַק"

而且我找不到删除字母下方标志的有效方法。

试过纵梁,用 str_replace_all(sample1, "[^[:alnum:]]", "")试过 gsub('[:punct:]','',sample1)
没有成功... :-(
有任何想法吗?

最佳答案

您可以使用 \p{M} Unicode 类别将变音符号与类似 Perl 的正则表达式相匹配,以及 gsub所有这些都像这样:

sample1 <- "הֻסְמַק"
gsub("\\p{M}", "", sample1, perl=T)

结果: [1] "הסמק"
demo

\p{M} or \p{Mark}: a character intended to be combined with another character (e.g. accents, umlauts, enclosing boxes, etc.).



查看更多 Regular-Expressions.info, "Unicode Categories" .

关于regex - 使用 r 删除希伯来语 "niqqud",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32637651/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com