I am using regular expressions in Eclipse IDE. I am trying to turn
other.test
into other.getTest()
Search: other.([a-z])([a-z]*
Unfortunately, Eclipse Find/Replace regex does not support case modifying operators like \U
, \u
, \L
and \l
. You may either use a long workaround suggested by jrahhali, or use Notepad++:
Search: other\.([a-z]+)
Replace: other.get\u$1\(\)
Explantion:
other\.
- matches a string other.
(note the dot must be escaped to match a literal dot)([a-z]+)
- Group 1 capturing 1 or more lowercase ASCII letters (check Match case option to only match lowercase ASCII letters with [a-z]+
)Replacement pattern details:
other.get
- a literal text other.get
\u$1
- the contents of Group 1 (the $1
is a backreference to the captured group 1) and its first character is turned to upper case with \u
operator (\U
would turn the whole text of the capture group to upper case)\(\)
- a literal text ()
(the parentheses should be escaped in NPP Boost conditional replacement patterns).Demo screen:
simple one.. according to http://www.regexe.com/ it works fine:
search pattern - other\.t(est)
replace pattern - other\.getTest\(\)
Good luck..
This works. You need two passes with search and replace. Reference from this answer: Is it possible to transform to lowercase using Eclipse's regex search and replace?
search 1: other\.([a-z])([a-z]*)
replace 1: other.ABCDEFGHIJKLMNOPQRSTUVWXYZ$1$2
search 2: other\.(A)BCDEFGHIJKLMNOPQRSTUVWXYZa|A(B)CDEFGHIJKLMNOPQRSTUVWXYZb|AB(C)DEFGHIJKLMNOPQRSTUVWXYZc|ABC(D)EFGHIJKLMNOPQRSTUVWXYZd|ABCD(E)FGHIJKLMNOPQRSTUVWXYZe|ABCDE(F)GHIJKLMNOPQRSTUVWXYZf|ABCDEF(G)HIJKLMNOPQRSTUVWXYZg|ABCDEFG(H)IJKLMNOPQRSTUVWXYZh|ABCDEFGH(I)JKLMNOPQRSTUVWXYZi|ABCDEFGHI(J)KLMNOPQRSTUVWXYZj|ABCDEFGHIJ(K)LMNOPQRSTUVWXYZk|ABCDEFGHIJK(L)MNOPQRSTUVWXYZl|ABCDEFGHIJKL(M)NOPQRSTUVWXYZm|ABCDEFGHIJKLM(N)OPQRSTUVWXYZn|ABCDEFGHIJKLMN(O)PQRSTUVWXYZo|ABCDEFGHIJKLMNO(P)QRSTUVWXYZp|ABCDEFGHIJKLMNOP(Q)RSTUVWXYZq|ABCDEFGHIJKLMNOPQ(R)STUVWXYZr|ABCDEFGHIJKLMNOPQR(S)TUVWXYZs|ABCDEFGHIJKLMNOPQRS(T)UVWXYZt|ABCDEFGHIJKLMNOPQRST(U)VWXYZu|ABCDEFGHIJKLMNOPQRSTU(V)WXYZv|ABCDEFGHIJKLMNOPQRSTUV(W)XYZw|ABCDEFGHIJKLMNOPQRSTUVW(X)YZx|ABCDEFGHIJKLMNOPQRSTUVWX(Y)Zy|ABCDEFGHIJKLMNOPQRSTUVWXY(Z)z([a-z]*)
replace 2: other.get$1$2$3$4$5$6$7$8$9$10$11$12$13$14$15$16$17$18$19$20$21$22$23$24$25$26$27