I keep reading the sed
documentation and lots of posts but can't seem to figure this out. I have a large number of Java files. In those files are calls to a method that take the enumeration converted to an integer using the toInt()
method. I want to go through all of the files and get rid of .toInt()
for a specific enumeration.
This is what I want. The original code strings:
foo(ENUM_NAME.ENUM_VALUE.toInt(), arg2, arg3)
foo(ENUM_NAME.ENUM_VALUE2.toInt(), arg2, arg3)
I want to end up with:
foo(ENUM_NAME.ENUM_VALUE, arg2, arg3)
foo(ENUM_NAME.ENUM_VALUE2, arg2, arg3)
ENUM_VALUE
could be hundreds of different possibilities so I can't hard code. It appears there is some confusion as to what needs to change so I will try to be more clear.
There is an enumeration called TRANF_FIELD
in my Java files. The values available for that enumeration could be one of a two thousand values, followed by .toInt()
. I need to get rid of the .toInt()
. The function names are all irrelevant.
The following are examples of code constructs that are interspersed throughout my Java code and how they should be processed:
TRANF_FIELD.TRANF_VALUE_1.toInt()
I want the.toInt()
deleted, leavingTRANF_FIELD.TRANF_VALUE_1
left over.
TRANF_FIELD.TRANF_KILL_ME.toInt()
I want the.toInt()
deleted, leavingTRANF_FIELD.TRANF_KILL_ME
TRANG_FIELD.TRANG_VALUE_1.toInt()
No change, because it's notTRANF_FIELD
.
TRANF_FIELD.TRANF_VALUE_1.length()
No change, because it's not.toInt()
.
string(string.string.string(), string, string)
and you will always want to get rid just of thestring()
? Can it bestring(string.string(), string)
for example? – confused00 Oct 7 '14 at 15:13awk -vFS='[.)]' '{print $1"."$2$4")"}'
– confused00 Oct 7 '14 at 15:20