gpt4 book ai didi

regex - vim 正则表达式 : deleting character based on position

转载 作者:行者123 更新时间:2023-12-02 21:49:13 24 4
gpt4 key购买 nike

这类似于问题VIM: insert or delete data based on position

我试图在文件中每一行的位置 7 处替换(而不仅仅是插入)所需的文本。根据上述问题的解决方案中提供的正则表达式,我尝试了:

a. %s/\%=7c/text/  (failed error message - illegal character)
b. %s/\%7c/text/g (says correct amount of lines / changes were made BUT blank space is still there after "text")
c. %s/\%7c/text/ (same as b)

最佳答案

/%7c 将插入到字符 7

您希望匹配如下,以便它包含下一个字符:

%s/\%7c./text/

关于regex - vim 正则表达式 : deleting character based on position,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18984755/

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