How do i delete everything except the square brackets
-
Dear community,
how do i delete the whole text / character etc, except the things what stands between the square brackets?
Example text:
Lorem ipsum [dolor] sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit [amet]. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et [accusam] et justo duo dolores et [ea] rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Filtered as a result come out:
dolor
amet
ea
accusamSorry for my bad english, im german.
In German:
Hallo liebe Community,
wie mache ich mit Notepad++ mittels RegExp den ganzen Text/Zeichen etc löschen außer die Sachen was zwischen den eckigen klammer steht?
Beispiel Text:
Lorem ipsum [dolor] sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit [amet]. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et [accusam] et justo duo dolores et [ea] rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
gefiltert soll als Ergebnis sowas rauskommen:
dolor
amet
ea
accusam -
Hi there.
I figured out this much before my head started hurting:
Find What:
[^\[\]]*\[([^\]]+)\]
Replace:\1\n
It gives what you want but just leaves the last line intact:
dolor
amet
accusam
ea
rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. -
Couldn’t let it go…
Find What:[^\[\]]*\[([^\]]+)\]|.*$
Replace:\1\n
Don’t forget to enable “Regular expression” - then click “Replace All”.
-
-
Hi, nice one but I guess there is little issue as you use
[^\[\]]
whereas, I believe, it should be
[^\[]
because otherwise a text like
blabla] blabla [needed_text] blabala
will break your logic.
Cheers
Claudia