gpt4 book ai didi

vim中的正则表达式unicode字符

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

我真是个白痴。

有人从 Microsoft Word 中剪切并粘贴了一些文本到我可爱的 ​​html 文件中。

我现在有这些 un​​icode 字符而不是常规引号符号(即引号在文本中显示为 <92>)

我想要进行正则表达式替换,但我在选择它们时遇到了问题。

:%s/\u92/'/g
:%s/\u5C/'/g
:%s/\x92/'/g
:%s/\x5C/'/g

...全部失败。我的 google-fu 失败了。

最佳答案

来自 :help regexp (稍作编辑),您需要使用一些特定的语法来在 Vim 中使用正则表达式选择 unicode 字符:

\%u match specified multibyte character (eg \%u20ac)

也就是说,要搜索十六进制代码 20AC 的 unicode 字符,请在搜索模式中输入以下内容:

\%u20ac

字符搜索模式的完整表包括一些附加选项:

\%d match specified decimal character (eg \%d123)
\%x match specified hex character (eg \%x2a)
\%o match specified octal character (eg \%o040)
\%u match specified multibyte character (eg \%u20ac)
\%U match specified large multibyte character (eg \%U12345678)

关于vim中的正则表达式unicode字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3016965/

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