1

I have this text opened in notepad++ 7.5.2 text editor :

- Note 1 message={"one":1}]
- Note 5 message={"two":2}]
- Note 2 message={"three":3}]
- Note 7 message={"four":4}]

For each line, I want to keep only the text between the brackets starting and ending brackets { } and the bracket themselves. I tried a regex - Note.* message= in https://regex101.com/ and it works. I am able to find lines in matching the regex in notepad++. But, I am not able to replace them with nothing.

How do I do the replacement ?

4
  • 2
    Like here, regex101.com/r/niH1ba/2? Commented Oct 29, 2019 at 23:05
  • @WiktorStribiżew - Thanks. I set "Find what" as ^- Note.* message=(.*)]$ and "Replace with" as $1. Notepad++ says 0 occurrences were replaced. I have selected the regex option in find. So, I don't know why this is not working. Commented Oct 29, 2019 at 23:09
  • @WiktorStribiżew - I selected all the text in my temp document and then tried the replace all. It works now. Thanks. Please add this as an answer. I can accept it. thanks Commented Oct 29, 2019 at 23:16
  • Find: .*=|\] replace all with nothing Commented Apr 28, 2021 at 4:07

1 Answer 1

2

You may use

^- Note.* message=(.*)]$

Replace with $1. See the regex demo.

Details

  • ^ - start of a line
  • - Note - - Note text
  • .* - any 0+ chars other than line break chars, as many as possible
  • message= - message= text
  • (.*) - Capturing group 1 ($1): any 0+ chars other than line break chars, as many as possible
  • ] - a ] char
  • $ - end of a line.

Notepad++ demo and settings:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.