Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace uppercase letters to lowercase letters using regex in Eclipse?

People also ask

How do I change capital letters to lowercase in eclipse?

CTRL + SHIFT + Y changes to lowercase. CTRL + SHIFT + X changes to UPPERCASE.

How do you match upper and lower cases in regex?

Using character sets For example, the regular expression "[ A-Za-z] " specifies to match any single uppercase or lowercase letter. In the character set, a hyphen indicates a range of characters, for example [A-Z] will match any one capital letter.

How do you uppercase in regular expressions?

This can be done easily using regular expressions. In a substitute command, place \U or \L before backreferences for the desired output. Everything after \U , stopping at \E or \e , is converted to uppercase. Similarly, everything after \L , stopping at \E or \e , is converted to lowercase.


I just resolved the same task (had to turn .net interface into java interface) utilizing the power of VIM :)

void DoMethod1 -> void doMethod1
Foo PerformMethod2 -> Foo performMethod2
:%s/\(^\s*\w\+\s\+\)\([A-Z]\)/\1\L\2/g

Here we are searching for (optional indentation followed by return type followed by whitespace) followed by (Uppercase letter). Braces are capturing groups. Then we are performing a replacement first capturing group \1 lowercase \L second capturing group \2.

This of course requires you to open file in Vim, but anyway this is much faster then doing the same thing by hand in Eclipse.


That is not possible. Either use Eclipse's re-factoring functionality, or replace them one at a time:

regex       : \bk_A
replacement : k_a 

regex       : \bk_B
replacement : k_b 

...

regex       : \bk_Z
replacement : k_z 

I needed to do this for a huge chunk of source code where string literals needed to be converted to lowercase. I found a way using Notepad++ and the Python Script plugin, as used here.