[英]How do I find and replace certain text in Visual Studio Code regex?
So I'm editing some old Lua code I wrote, and I'm trying to optimize it. 因此,我正在编辑我编写的一些旧的Lua代码,并且正在尝试对其进行优化。 I made a bunch of mistakes like using
table.insert()
and :len()
when I should've used the faster Table[#Table + 1] = _
and #String
. 当我应该使用更快的
Table[#Table + 1] = _
和#String
时,我犯了很多错误,例如使用table.insert()
和:len()
。 I have the code pasted into my Visual Studio Code, and I want to quickly replace them all. 我已将代码粘贴到我的Visual Studio代码中,我想快速替换它们。 I think I already have the find RegEx for the
:len()
, but I just don't know how to make it replace it with the same value, and I certainly am unsure on how to make the table.insert
work. 我想我已经为
:len()
找到了RegEx,但是我只是不知道如何用相同的值替换它,而且我不确定如何使table.insert
工作。
.:len\\(\\)
is what I have for my find RegEx on the code, but I don't know how I'm supposed to replace it while keeping the previous value. .:len\\(\\)
是我在代码中找到RegEx的功能,但是我不知道在保留以前的值的情况下应该如何替换它。 Can anyone help a complete idiot out? 谁能帮助一个完整的白痴? Thanks!
谢谢!
Not really too sure what you mean by "replace it but keep old value" perhaps you could give an example? 不太确定“替换但保留旧值”是什么意思,也许您可以举个例子?
I'm guessing the problem is keeping the argument while replacing the outer syntax? 我猜问题是在替换外部语法时保留参数吗? In which case use sub str parens matching: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Using_parenthesized_substring_matches_2
在这种情况下,请使用sub str parens匹配: https : //developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions#Using_parenthesized_substring_matches_2
eg table\\.insert\\(([\\s\\S\\r\\n]*?)\\)
with new($1)
例如
table\\.insert\\(([\\s\\S\\r\\n]*?)\\)
与new($1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.