Search code examples
regexeclipsenotepad++replace

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!


Solution

  • 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.