regex - How to use regular expressions with Eclipse's find/replace to refactor code -
i'm still developing regex skills, i'm leaning on community. want refactor code "with eclipse", i've used number of ide's search , replace functions accept regular expressions. i've create general expressions find things, wonder if can take portions of matched pattern , use in replacement value. example, have lot of test functions named following pattern" "testsomefunction1(), testsomefunction2(), testanotherfunction()" i'd them named "test_somefunction1(), test_somefunction2(), test_anotherfunction()". find: "test[a-z]", use replace with:? "test_[a-z]" literally replacing? perhaps, cannot use regex statement in replacement?
for sample text you've posted, find expression should test([a-z]*)
, replace should test_$1
.
this makes use of captured groups referenced $i
i
captured group index (0
entire expression). may want consider case of search string since text permutestring
match expression if search case-insensitive.
you should able use content-assist in text fields of find/replace
dialog see options available regular expressions (once you've checked box regular expressions
) - press ctrl+space
Comments
Post a Comment