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

2
  • 1
    Notepad don't have regex functionality. Do you mean notepad++? Jun 13, 2019 at 15:56
  • Oh, sorry! I use notepad++ for so long time that I forgot that notepad exists too :D
    – Zhenya
    Jun 13, 2019 at 16:04

2 Answers 2

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.

2
  • 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, 2019 at 15:59
  • Oh, sorry! I use notepad++ for so long time that I forgot that notepad exists too :D
    – Zhenya
    Jun 13, 2019 at 16:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .