Notepad++, replace with regular expression and maintain some variable letters

Example, I have a file that contains many many of the next:

"xxxxxx".toLowerCase() 

xxxxxx - some text with variable length.

I want to replace it with:

castlowercase("xxxxxx") 

I don't find how to make a regular expression. It's better to take everything between ( ) cause there may be some variable, not just a string...

2

2 Answers

  • Ctrl+H
  • Find what: ("[^"]+")\.toLowerCase\(\)
  • Replace with: castlowercase\($1\)
  • check Match case
  • check Wrap around
  • check Regular expression
  • Replace all

Explanation:

( # start group 1 " # a quote [^"]+ # 1 or more any character that is not a quote " # a quote ) # end group 1 \. # a dot toLowerCase\(\) # literally toLowerCase() 

Replacement:

castlowercase # literally \( # openning parenthesis, must be escaped in Notepad++ $1 # content of group 1 (i.e. "xxxxxxx") \) # closing parenthesis, must be escaped in Notepad++ 

Result for given example:

castlowercase("xxxxxx") 

Screen capture:

enter image description here

Notepad can't do regular expressions. It is a very basic editor.
So you are asking the impossible.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like