VS代码,在替换字段中查找/替换访问查找结果(VS Code, find/replace access find results in the replace field)

我在我的文件上有电话号码,我想用括号括住每个号码,所以如果我有这样的话:

"+49-1111" "+49-2222"

我想运行一个替换操作,并得到这个:

["+49-1111"] ["+49-2222"]

用当前的代码查找/替换操作有可能吗? 如果这是一个重复的抱歉,但我可以在任何地方找到任何解释。 谢谢

I have phone numbers on my file and I would like to surround each of them with braces, so if I have this:

"+49-1111" "+49-2222"

I would like to run a replace operation and to get this:

["+49-1111"] ["+49-2222"]

Is that possible with the current vs code find/replace action? If it is a dup sorry but I could find any explanation anywhere. Thanks

最满意答案

这与正则表达式更相关。

查找("\+\d{2}-\d{4}") ,用[$1]替换出现的地方

确保打开“使用正则表达式”开关。

This is more relevant to regular expression.

Find ("\+\d{2}-\d{4}"), replace the occurrences with [$1]

Be sure to turn the "Use Regular Expression" switch on.

VS代码,在替换字段中查找/替换访问查找结果(VS Code, find/replace access find results in the replace field)

我在我的文件上有电话号码,我想用括号括住每个号码,所以如果我有这样的话:

"+49-1111" "+49-2222"

我想运行一个替换操作,并得到这个:

["+49-1111"] ["+49-2222"]

用当前的代码查找/替换操作有可能吗? 如果这是一个重复的抱歉,但我可以在任何地方找到任何解释。 谢谢

I have phone numbers on my file and I would like to surround each of them with braces, so if I have this:

"+49-1111" "+49-2222"

I would like to run a replace operation and to get this:

["+49-1111"] ["+49-2222"]

Is that possible with the current vs code find/replace action? If it is a dup sorry but I could find any explanation anywhere. Thanks

最满意答案

这与正则表达式更相关。

查找("\+\d{2}-\d{4}") ,用[$1]替换出现的地方

确保打开“使用正则表达式”开关。

This is more relevant to regular expression.

Find ("\+\d{2}-\d{4}"), replace the occurrences with [$1]

Be sure to turn the "Use Regular Expression" switch on.