Community
    • Login

    How to create a remove "Search Mode: Regular expression"

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    20 Posts 7 Posters 936 Views
    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.
    • Red OrbR
      Red Orb @astrosofista
      last edited by

      @astrosofista
      Thanks for reply, appreciate it!

      Sorry for not explaining correctly…
      Here is a screen dump and here is text:

      {This, and that, remove and replace including å Å ä Ä ö Ö numbers and ; : ? ! .
      Sorry for bad explanation on what I’m trying to achieve.}

      Red

      Alan KilbornA 1 Reply Last reply Reply Quote 1
      • Alan KilbornA
        Alan Kilborn @Red Orb
        last edited by Alan Kilborn

        @Red-Orb

        That clarification doesn’t seem to clarify anything.
        From what I can tell – I can’t believe I’m joining the group of “guessers”-- it appears that @guy038 's solution of (?s)\{.+?\} is what is desired.

        Red OrbR 1 Reply Last reply Reply Quote 0
        • Red OrbR
          Red Orb @Alan Kilborn
          last edited by Red Orb

          @Alan-Kilborn
          Did you see the image?
          I don’t know how to explain?
          I have these lines with {} in a textfile and I want to remove the brackets {} and all text inside brackets [}.
          I want to use a regular expression to remove them.
          And… this seems to work
          (?s){.+?}

          Thanks and best regards
          Red

          Alan KilbornA astrosofistaA 2 Replies Last reply Reply Quote 1
          • Red OrbR
            Red Orb @guy038
            last edited by

            @guy038
            Thanks for your help! :D

            1 Reply Last reply Reply Quote 1
            • Alan KilbornA
              Alan Kilborn @Red Orb
              last edited by Alan Kilborn

              @Red-Orb said in How to create a remove "Search Mode: Regular expression":

              Did you see the image?

              Yes, it didn’t add any info AFAICT.

              And… this seems to work

              (?s){.+?}

              Well, that is basically @guy038 's solution from before, which you hadn’t previously indicated that it did or didn’t work for you, or even if you tried it.
              But since { and } have special meaning for regular expressions, @guy038 “escaped” them for use as a literal text match, using the syntax \{ and \}.
              It can work without the escaping, but it is a dangerous habit to get into.

              Red OrbR 1 Reply Last reply Reply Quote 1
              • Red OrbR
                Red Orb @Alan Kilborn
                last edited by

                @Alan-Kilborn
                OK! I’m trying to understand how I could explain in any other way than showing a screendump and in explaining text.
                Can you understand now what I’m trying to achieve?
                If you have any input on how to create a “safe” habit I would really appreciate it.

                Best regards,
                Red

                PeterJonesP 1 Reply Last reply Reply Quote 0
                • astrosofistaA
                  astrosofista @Red Orb
                  last edited by

                  @Red-Orb said in How to create a remove "Search Mode: Regular expression":

                  I have these lines with {} in a textfile and I want to remove the brackets {} and all text inside brackets [}.

                  At least to me, that’s an understandable explanation of your needs, and shows that I was way wrong. Bad luck :)

                  Red OrbR Alan KilbornA 2 Replies Last reply Reply Quote 0
                  • Red OrbR
                    Red Orb @astrosofista
                    last edited by

                    @astrosofista
                    Thanks!

                    1 Reply Last reply Reply Quote 0
                    • Alan KilbornA
                      Alan Kilborn @astrosofista
                      last edited by

                      @astrosofista said in How to create a remove "Search Mode: Regular expression":

                      “I have these lines with {} in a textfile and I want to remove the brackets {} and all text inside brackets {}.”
                      At least to me, that’s an understandable explanation of your needs,

                      Yes, that’s understandable, but with all the earlier extra information about specific unicode characters and digits, it was all open to wider interpretation.

                      If you have any input on how to create a “safe” habit

                      Well, it just comes from experience; in this case, experience with regular expressions.
                      And of course that comes from studying the docs. And practice and more practice.
                      This one was a strange case, because it does indeed work as if { and } have no special meaning.

                      1 Reply Last reply Reply Quote 1
                      • PeterJonesP
                        PeterJones @Red Orb
                        last edited by PeterJones

                        @Red-Orb said in How to create a remove "Search Mode: Regular expression":

                        how I could explain in any other way than showing a screendump and in explaining text.

                        You could read the advice I posted:

                        • include all text as text in your post, marked up using the </> button
                          065fee87-a1f1-4fa5-9204-8ff0e610732b-image.png
                        • you could show the text you have before the search-and-replace operation, as well as the text you want after the search-and-replace operation
                        • when you do embed images (which are only necessary if there’s something in the graphics that will add clarity that the text doesn’t show, like highlighting), actually embed them using the image button from the same toolbar above
                          7f628367-d23b-41ad-9b07-33a38ec32979-image.png
                          so that it shows up in your post, rather than making us click, like:
                          alt text
                          or, easier, for static images, just copy your screenshot into your clipboard, then Ctrl+V to paste the image directly into your post without uploading to imgur.
                        • Include examples of what to modify and what not to modify

                        All of that was stated above.

                        So, for your example, you could have said,

                        Hello, I have the text where I would like to delete everything between the curly braces, including the curly braces.
                        For example:

                        this I want to keep
                        {this I want to delete, even with numbers like 1 or other special characters like å Å}
                        more to keep {more to delete} more to keep
                        and even {delete a
                        multi-line
                        braced expression} something more
                        

                        I would like to delete everything inside the curly braces {...}, including the curly braces themselves, so that it will look like

                        this I want to keep
                        
                        more to keep more to keep
                        and even something more
                        

                        In a few brief lines, that would have told us everything we needed to know – by giving examples both where the braces are alone on a line and examples where they are inline with other text, we could see your desired result, and know that you wanted to match even if {...} was embedded between other text, or when {...} spans across multiple rows.

                        1 Reply Last reply Reply Quote 2
                        • red orb 0R
                          red orb 0
                          last edited by

                          @Alan Kilborn
                          Thanks and best regards
                          Red

                          @PeterJones
                          OK! I’ll save this as a textfile and try to use your helpful info next time I need advice.
                          About using imgur I thought it would be better to upload than to use the clipboard as it was a large image?
                          Thanks and best regards
                          Red

                          PS/
                          For reasons I cannot understand my earlier profile in here was deleted?

                          1 Reply Last reply Reply Quote 0
                          • PeterJonesP
                            PeterJones
                            last edited by

                            @red-orb-0 said in How to create a remove "Search Mode: Regular expression":

                            About using imgur I thought it would be better to upload than to use the clipboard as it was a large image?

                            If you want to upload to imgur first, you may. I embedded your image, still housed on imugr, by clicking the button. That button inserted the text ![alt text](image url), with imgage url highlighed. I pasted the imgur URL https://i.imgur.com/W8orl27.jpg there so it became ![alt text](https://i.imgur.com/W8orl27.jpg), and voila, the image was embedded here while still hosted at imgur.

                            But pasting the image directly here, so the URL becomes something like https://community.notepad-plus-plus.org/assets/uploads/files/1589468012401-7f628367-d23b-41ad-9b07-33a38ec32979-image.png (my image button, above) means that all readers here will be able to see it; many of the regulars are checking here during their coffee breaks at work, or reading to get an answer they need to accomplish their job, but some IT departments block sites like imgur as not being work-related.

                            my earlier profile in here was deleted?

                            No. @Red-Orb (https://community.notepad-plus-plus.org/user/red-orb) and @red-orb-0 (https://community.notepad-plus-plus.org/user/red-orb-0) are two independent accounts, but both still exist. Did you sign into one using google and the other facebook, or some such?

                            redorbroderR 1 Reply Last reply Reply Quote 2
                            • redorbroderR
                              redorbroder @PeterJones
                              last edited by redorbroder

                              @PeterJones
                              I will keep all your helpful information on how to post correctly, I really apprecite your help! Thanks!
                              About my profile/account.
                              I have no idea what’s going on with login and user profile?
                              I only login using google and there’s the culprit I think?
                              Couldn’t login today again… ? Very annoying!
                              So I’m still the same Red Orb though and will try to figure out why google fails.
                              Best regards
                              Red

                              Edit:
                              Is there a way to delete old profiles in here! May be a mod can do that?

                              PeterJonesP 1 Reply Last reply Reply Quote 0
                              • PeterJonesP
                                PeterJones @redorbroder
                                last edited by

                                @redorbroder said in How to create a remove "Search Mode: Regular expression":

                                I have no idea what’s going on with login and user profile?
                                I only login using google and there’s the culprit I think?
                                Couldn’t login today again… ? Very annoying!

                                I’m not sure what’s going wrong for you. I am always logged in using my Google account. Today, just to make sure, I logged out, then followed the login procedure again:

                                1. 60767f5e-10eb-408c-94d0-46fdfeb03537-image.png
                                2. 9a40e2fb-fc4a-4204-8f93-4f79d38e12a6-image.png

                                I logged in just fine.

                                My next thought would be that you have more than one Google account, but picked a different one each time… but g

                                Hmm… I tried opening the login page with an incognito, so it didn’t have me already logged into Google. Then when I click “sign in with google”, it says:
                                bf2e63fb-f3fe-4fa3-b0d1-d2b85edf71ed-image.png

                                Here, you would enter your google account email, and click NEXT. If you click “Create account”, it will create a new account – so don’t do that. If you have multiple Community accounts created with the same Google account, I have no idea what the Community Forum software will do, how it would decide which to log in as.

                                Is there a way to delete old profiles in here! May be a mod can do that?

                                I don’t know whether that’s possible. @guy038 or one of the other moderators here might be able to help you. But I’d recommend figuring out your logging-in difficulties before deleting old accounts.

                                redorbroderR 1 Reply Last reply Reply Quote 1
                                • redorbroderR
                                  redorbroder @PeterJones
                                  last edited by

                                  @PeterJones
                                  Thanks for your help and info.
                                  I’ll just leave the accounts as they are, don’t want to mess things up…
                                  This account will be the one I use from now on.

                                  Best regards,
                                  Red

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post
                                  The Community of users of the Notepad++ text editor.
                                  Powered by NodeBB | Contributors