Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Case sensitive string replacement in Eclipse or Notepad++

I am using Eclipse and Notepad ++ to perform replacement multiple files (xml & java)

I am trying to replace [Pp]roduct[Mm]ember with [Ff]und[Mm]ember in one single replacement and preserving the case.

ProductMember -> FundMember
productMember -> fundMember
productmember -> fundmember

Using capturing groups it is easy to keep the case of the M from Member, but I am clueless for the P replacement.

Thanks for the help!

like image 504
jpboudreault Avatar asked Jan 11 '12 17:01

jpboudreault


People also ask

Is replace in Java case sensitive?

replace method is case sensitive.

How do I replace a string in Notepad ++?

To replace text in Notepad++, follow the steps below. Open the text file in Notepad++. In the top menu bar, click Search and select Replace. In the Replace window, on the Replace tab, enter the text you want to find and the text you want to use as a replacement.


1 Answers

In eclipse you can use the regex retain-case operator: \C. To solve your example you should search for "Product", replace with "\CFund" (be sure to tick the Regular expression option). This will replace Product with Fund and product with fund.

Update:

Make sure not to have the Case Sensitive box checked.

like image 128
Aleksander Blomskøld Avatar answered Oct 05 '22 18:10

Aleksander Blomskøld