Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using eclipse find and replace all to swap arguments

I have about 100 lines that look like the below:

assertEquals(results.get(0).getID(),1);

They all start with assertEquals and contain two arguments. Im looking for a way to use find and replace all to swap the arguments of all these lines.

Thanks

like image 993
Chris Avatar asked Oct 10 '11 20:10

Chris


1 Answers

use the following regexp to find:

assertEquals\((.*),(.*)\);

and this replacement value:

assertEquals(\2,\1);

The regexp means "assertEquals( followed by a first group of chars followed by a comma followed by a second group of chars followed by );".

The replacement value means "assertEquals( followed by the second group of chars found followed by a comma followed by the first group of chars found followed by );".

like image 56
JB Nizet Avatar answered Sep 19 '22 06:09

JB Nizet