Replace to Lower Case is not working in VS Code's Search View

huangapple go评论93阅读模式
英文:

Replace to Lower Case is not working in VS Code's Search View

问题

根据这个StackOverflow帖子,伴随着一个已合并并发布版本的GitHub PR链接,用户应该能够使用正则表达式在全局查找中将结果替换为小写。然而,这个功能对我来说不起作用,而我使用的VS Code版本要比这个发布的版本要晚得多(1.77.3)(1.47)。

您可以看到“HI”被替换为“\LHI”。

有人能解释一下如何替换为小写吗?请注意,我不打算使用命令面板中的“转换为小写”命令,因为那不会执行大规模的替换。

英文:

According to this StackOverflow post, accompanied by a link to a GitHub PR that has been merged and the version has been released, users should be able to replace the results in global find to lower case using Regex. However, this feature is not working for me, and I am using a much later version of VS Code (1.77.3) than this was released for (1.47).

You can see that "HI" is replaced with "\LHI".

Can someone please explain how to replace to lowercase? Note that I am not looking to use "Transform to Lowercase" command from the command palette, as that does not perform mass replace.

Replace to Lower Case is not working in VS Code's Search View

答案1

得分: 1

那种替换,使用\L$0在搜索替换中不起作用。您可以将整个内容包装在一个捕获组中,如下所示:

(\b(?:HI|HELLO)\b(?![A-Z a-z]))

然后用\L$1替换,它会按您的期望工作。$0在替换字段中确实有效,但不能与\L\U\l\u一起使用。

英文:

That kind of a replacement, using \L$0 doesn't work in the Search replace. You could just wrap the whole thing in a capture group like

(\b(?:HI|HELLO)\b(?![A_Za-z]))

and then replace with \L$1 and it works as you expect. $0 does work in the replace field just not together with \L, \U, \l or \u.

huangapple
  • 本文由 发表于 2023年6月9日 05:24:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76435782.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定