0

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

  • 1
    Notepad don't have regex functionality. Do you mean notepad++? – Máté Juhász Jun 13 at 15:56
  • Oh, sorry! I use notepad++ for so long time that I forgot that notepad exists too :D – Zhenya Jun 13 at 16:04
1
  • 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

-1

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

  • Really? I see that there is an option 'regular expression' :/ oh, ok, I see that there are online regex editors, but I need to understand how to make this replace with regex :) – Zhenya Jun 13 at 15:59
  • Oh, sorry! I use notepad++ for so long time that I forgot that notepad exists too :D – Zhenya Jun 13 at 16:05

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.