如何在 WebStorm/PhpStorm 中用正则表达式替换 [英] How to replace in WebStorm/PhpStorm with regex
本文介绍了如何在 WebStorm/PhpStorm 中用正则表达式替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想换
#{account_nbr}
与
{{account_nbr}}
在查找中,我试过这个:
in the find, I tried this:
\#\{()\w+\1\}
在替换中,这个:
{{\$1}}
查找似乎有效,但我无法正确获取反向引用.
The find seems to work but I can't get the backreference correctly.
怎么了?
推荐答案
您不需要任何反向引用,就像您使用它们的方式一样.
You do not need any backreferences the way you are using them.
这是您可以使用的正则表达式:
This is the regex you can use:
\#\{(\w+)\}
替换应该是
{{$1}}
当您使用 \$
时,使用的是文字 $
,而不是实际的反向引用.
When you use \$
, a literal $
is used, not the actual back-reference.
这篇关于如何在 WebStorm/PhpStorm 中用正则表达式替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文