在IntelliJ中查找带有区分大小写的替换文本

时间:2015-10-30 13:42:53

标签: regex intellij-idea replace find

我有一个包含许多自动生成方法的测试类,如下所示:

public void testInitBinder() throws Exception { }

public void testGetAllMetaLabelTbls() throws Exception { }

public void testList() throws Exception { }

public void testEdit() throws Exception { }

我想删除" test"在方法名称中,但是方法名称正确地以小写字母开头。例如,testInitBinder将成为initBinder

注意,这只是一个示例案例。我想知道在这种特定情况之外的其他情况下如何进行这种类型的查找/替换。 (告诉我如何在没有前缀的情况下自动生成"测试"不会回答这个问题。)

我的本​​地问题 enter image description here

1 个答案:

答案 0 :(得分:1)

您可以使用search and replace,选择您要使用正则表达式并使用类似的内容进行搜索/替换模式:

  • 搜索模式:void test([A-Z]{1})(.*)\(
  • 替换模式:void \L$1\E$2\(

请注意,这是一个相当粗略的解决方案,但在您的情况下可能已经足够了。

enter image description here