Community
    • Login

    How do i delete everything except the square brackets

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 3 Posters 3.0k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H3ker001H Offline
      H3ker001
      last edited by

      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
      accusam

      Sorry 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

      1 Reply Last reply Reply Quote 0
      • moon6969M Offline
        moon6969
        last edited by

        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.

        1 Reply Last reply Reply Quote 1
        • moon6969M Offline
          moon6969
          last edited by moon6969

          Couldn’t let it go…
          Find What: [^\[\]]*\[([^\]]+)\]|.*$
          Replace: \1\n

          Don’t forget to enable “Regular expression” - then click “Replace All”.

          Claudia FrankC 1 Reply Last reply Reply Quote 3
          • H3ker001H Offline
            H3ker001
            last edited by

            @moon6969 said:

            \1\n

            this is amazing ! ! ! thank you =) ) )

            1 Reply Last reply Reply Quote 0
            • Claudia FrankC Offline
              Claudia Frank @moon6969
              last edited by

              @moon6969

              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

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors