更新时间:2023-02-23 08:18:30
如何在Intellij项目中使用正则表达式查找和替换文本
在本例中使用了 Intellij 2020.2.
In this case Intellij 2020.2 was used.
您会在菜单下找到替换工具:
You will find the replacement tool under menu:
编辑/查找/'在路径中替换...'
或走捷径:
Ctrl+Shift+R
在搜索窗口中输入:
(\w+) = new ItemBuilder\(Material\.valueOf\(\\"ACACIA_BOAT\\"
在替换窗口类型中:
$1 = new ItemBuilder\(Material\.valueOf\(\\"$1\\"
确保选择以下内容:
Match case 'Aa' - 位于搜索窗口"的右侧;(激活时亮蓝色)
Match case 'Aa' - found on the right hand side of "search window" (It is lit with blue color when it is activated)
Regex '.*' - 位于搜索窗口"的右侧;(激活时亮蓝色)
Regex '.*' - found on the right hand side of "search window" (It is lit with blue color when it is activated)
在项目中" - 位于左侧替换窗口"下方
'In Project' - found on the left hand side just under the "replacement window"
设置完成后点击全部替换"按钮执行请求.
After settings click button 'Replace All' to execute request.
下面是工具"的图片,使用请求的正则表达式:
Below is a picture of the "tool", using requested regex:
阅读有关 Intellij 的查找并替换为正则表达式"的更多信息;在:
Read more about Intellij's "Find and replace with regex" at: