Given the text
public void MyFunction(int i, String str, boolean doIt) {
Log.i(TAG, "Enter MyFunction(int i, String str, boolean doIt)");
I want to make some replacements on the second line, but not the first
public void MyFunction(int i, String str, boolean doIt) {
Log.i(TAG, "Enter MyFunction( i:" + i + ", str:" + str ", doIt:" + doIt + ")");
So far using the following regex I manage to get these results:
find “\w+\s+(\w+)([,\)])“
replace with “$1:" + $1 + "$2“
public void MyFunction(i:" + i + ", str:" + str ", doIt:" + doIt + ") ") {
Log.i(TAG, "Enter MyFunction( i:" + i + ", str:" + str ", doIt:" + doIt + ") ");
Is there any way to force the replace to be executed only on the Log.i lines?
EDIT:
I tried the following regex
“Log\.i\(.*?\((\s*(\w+\s+(\w+)([,\)]))+“
but $1,$2,$3 only contains the last match (the last argument: doIt)
$1=boolean doIt)
$2=doIt
$3=)
when there should be 3 sets of $1,$2,$3, one for each argument.
If you know how to retrieve multiple matches, that would also make for a solution
I caved,
I used this little perl to do the job:
with the command line:
If someone still wants to contribute some, I understand I could have run perl as Eclipse external tool to process the java files. How do I do that?
UPDATE:
I wrote a post on how to use external perl to run the script from within Eclipse IDE
see the post