Sublime Text 搜索和替换

Sublime Text 搜索和替换

我想更换我所有的

$r->fields[variables]

$r->fields["variables"]

谁能告诉我怎么做?

答案1

您可以使用:

  • Ctrl+H
  • 寻找:\$\w+->\w+\[\K\w+
  • 代替:"$0"
  • Replace all

解释:

\$          # $ sign
\w+         # 1 or more word character
->          # literally
\w+         # 1 or more word character
\[          # [ character
\K          # forget all we have seen until this position
\w+         # 1 or more word character (you can use .+? if your variable contains other character than word character)

截图(之前):

在此处输入图片描述

截图(之后):

在此处输入图片描述

相关内容