• Login
Community
  • Login

help to delete part of line

Scheduled Pinned Locked Moved General Discussion
25 Posts 6 Posters 2.7k 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.
  • C
    cisco779k
    last edited by Dec 7, 2020, 7:18 PM

    and I also hope that this time my writing is correct… is ever that someone does not understand a tanxs with a thank you…

    P 1 Reply Last reply Dec 7, 2020, 8:10 PM Reply Quote 0
    • P
      PeterJones @cisco779k
      last edited by Dec 7, 2020, 7:57 PM

      This post is deleted!
      1 Reply Last reply Reply Quote 1
      • P
        PeterJones @cisco779k
        last edited by PeterJones Dec 7, 2020, 8:10 PM Dec 7, 2020, 8:10 PM

        @cisco779k,

        I am sorry if you felt attacked.

        I’ll just give you the answer that I obfuscated above. This works with your example text. I make no guarantee about your whole file.

        ----
        Since it looks like what you really want it to do is to merge the plaintext-on-a-single-line with the subsequent line, and strip out all the HTML and just leave the plain text with space separation, I would suggest

        • FIND = \R+<!---->|<.*?>
          • if there’s a newline followed by <!---->, delete the newline and the comment-tag, because that will then merge the standalone line with the line after it
          • if there’s any other html open or close tag, just delete it.
        • REPLACE = empty
        • MODE = regular expression

        ----

        I will do my best to avoid responding to you in the future. If you want to help me not reply to you, then I ask that you don’t change your username or create a new login, because otherwise I might be tempted to try to answer that new name for the same person.

        Good luck.

        1 Reply Last reply Reply Quote 2
        • C
          cisco779k
          last edited by Dec 7, 2020, 9:55 PM

          beyond your regex (which I will now try) I thank you for understanding my thoughts.
          I don’t understand why you say that in the future you would like to avoid answering… perhaps to avoid controversy. That is whether that is the reason, I repeat, there is no point in making polemics.
          but if instead you want to help me or others who present similar problems, I believe that every advice is welcome by anyone.
          so why avoid help (or answer) if you know how to do it and someone here asks for help? I think helping each other is a good thing.
          as far as I’m concerned your future responses to my posts will always be welcome.
          greeting and thank you for your help.

          A 1 Reply Last reply Dec 8, 2020, 12:19 AM Reply Quote 0
          • C
            cisco779k
            last edited by Dec 7, 2020, 10:03 PM

            your regex work fine.
            thank you for your support.

            1 Reply Last reply Reply Quote 0
            • A
              Alan Kilborn @cisco779k
              last edited by Alan Kilborn Dec 8, 2020, 12:20 AM Dec 8, 2020, 12:19 AM

              @cisco779k said in help to delete part of line:

              beyond your regex (which I will now try) I thank you for understanding my thoughts.
              I don’t understand why you say that in the future you would like to avoid answering… perhaps to avoid controversy. That is whether that is the reason, I repeat, there is no point in making polemics.
              but if instead you want to help me or others who present similar problems, I believe that every advice is welcome by anyone.
              so why avoid help (or answer) if you know how to do it and someone here asks for help? I think helping each other is a good thing.

              I think the problem is that this isn’t a regex site, and continual back and forth about typical data conversions isn’t very interesting to those that participate here. If that’s what you’re looking for, then perhaps try to find a support site that strictly deals in regex; they would probably welcome your problems there with open arms, and give you as many solutions as you want.

              We want to talk about Notepad++, and while regex is a part of Notepad++, what we want to do with it is get people interested in solving their own problems with it, not continually just offering up solution after solution to those that don’t care to put in the effort to learn.

              So, while we’re all about helping someone “get started”, I think those are the roots of the story…

              1 Reply Last reply Reply Quote 2
              • G
                guy038
                last edited by guy038 Dec 8, 2020, 12:21 PM Dec 8, 2020, 4:14 AM

                Hi, @cisco779k, @astrosofista, @alan-kilborn, @peterjones and All,

                The @peterjones’s regex S/R, below, works fine !

                SEARCH (?-s)\R<!-+>|<.*?>

                REPLACE Leave EMPTY

                However it remains some additional space characters !


                Also, in addition, here are two regex S/R to manage space and tabulation characters, in any situation :

                The first one :

                • Do not change any leading space or tabulation characters

                • Replaces any consecutive range of space or tabulation chars, between words, with a single space char

                • Deletes all trailing blank characters

                SEARCH (\h+)$|^\h+(*SKIP)(*F)|\h{2,}|\t

                REPLACE ?1:\x20


                If you prefer, also, to delete the leading space or tabulation chars, use this second one :

                SEARCH (^\h+|\h+$)|\h{2,}|\t

                REPLACE ?1:\x20

                which :

                • Trims all leading and trailing blank characters

                • Replaces any consecutive range of space or tabulation chars, between words, with a single space char

                Best Regards

                guy038

                1 Reply Last reply Reply Quote 1
                • C
                  cisco779k
                  last edited by Dec 8, 2020, 8:32 AM

                  @ guy038
                  thank you very much for your help, always much appreciated

                  @ Alan Kilborn
                  you’re right, I think this isn’t the right section to ask for these things. but I didn’t find a better section to post to, nor even a specific site to discuss regex… do you have any suggestions?
                  and not getting any better (since here for many of you are simple things) I thought you ask for help here, waiting for suggestions on other sites/specific sections…

                  1 Reply Last reply Reply Quote 0
                  • C
                    cisco779k
                    last edited by Dec 8, 2020, 8:40 AM

                    and while i’m still here, i take advantage of it (again!) to ask another topic:
                    how can i put a bookmark only on even lines of a list?
                    or how to delete even lines in a list?
                    or even: can i put a bookmark only on specific ranges of lines? (even ones, in my specific case)

                    A 1 Reply Last reply Dec 8, 2020, 1:53 PM Reply Quote 0
                    • T
                      Terry R
                      last edited by Dec 8, 2020, 11:08 AM

                      @cisco779k said in help to delete part of line:

                      bookmark only on even lines of a list?

                      I’m not on a PC as it’s late here, but here is a possible solution which is achievable for someone with limited regex experience.

                      As you say a list, that presumes it is part of a file rather than all lines, although my idea works for both.

                      1. Select the lines if some of the file or put cursor in first position of file if all lines.
                      2. Use the column editor to insert numbers, starting with 1, increase by 1, and set repeat to 1 (might need to be 2 , I haven’t used this option). No need to have leading zeroes but we do want each number listed twice.
                      3. Create a regex which looks at a number and also the one on the next line. If both the same then delete the one on the odd line, which is most likely the first one.
                      4. Once every 2nd number removed, use the bookmark feature to mark the (even) lines which have a number at the start.
                      5. Remove the numbers at the start of the line.

                      Terry

                      1 Reply Last reply Reply Quote 1
                      • G
                        guy038
                        last edited by guy038 Dec 8, 2020, 10:08 PM Dec 8, 2020, 12:02 PM

                        Hi, @cisco779k, @astrosofista, @alan-kilborn, @peterjones, @terry-r and All,

                        EDIT : In this post, I’m answering, specifically, to the @cisco779k’s question : how to delete even lines in a list?

                        Ah ! Interesting problem ! Here is a nice regex solution :

                        SEARCH (?-s)(.*\R).*\R?

                        REPLACE \1


                        IMPORTANT :

                        • The current line, even empty, becomes, by default, the virtual line 1, whatever the cursor location. So :

                          • This virtual line 1 is kept

                          • The virtual line 2 is deleted

                          • The virtual line 3 is kept

                        and so on…

                        • By default, the regex S/R processes all lines till the very end of current file

                        • If you want to restrict to a specific range of lines, simply use the In selection option of the Replace dialog

                        • Beware to not perform this regex S/R, using the Find in Files search tab or using the Replace in All Opened Documents button ;-)

                        • True empty lines are considered as valid lines, too !

                        • You may record this regex S/R as a macro


                        Test this regex S/R against that list of features and bug-fixes of the v7.9.1 change.log file !

                        1.  Fix NUL file-corruption bug after Windows shutdown brutally (Fix #6133).
                        2.  Fix inaccurate URL detection by replacing a new URL parser (Fix #3912, #3353, #4643, #5029, #6155, #7791, #8634)
                        3.  Fix RegEx look behind operations and \A and and \b and \z (Fix #713, #1870, #2216, #2360, #9004, #4855).
                        4.  Split functionList.xml into multifile in "functionList" Folder (Implement #4896).
                        5.  Make tray icon work again in administrator mode (Fix #8528).
                        6.  Fix dialogs & floating dockable panels don't minimize to system tray issue (Fix #9044, #8928).
                        7.  Add alternative icon set for tab bar (Implement #8068).
                        8.  Add ability to remove any duplicate lines in a document, keeping the first occurrence (Fix #8965).
                        9.  Fix incorrect icon for monitoring status in Document list panel and in Document switcher (Fix #8783).
                        10. Add copy marked text & styled text to clipboard commands to menu (Implement #8943, #6095).
                        11. Fix find-all-open-docs not finding all matches in ANSI files (Fix #8901).
                        12. Display long lines better in Find-result panel by increasing its max length to 2048 (Fix #7723).
                        13. Fix double clicking on find result line not working (Fix #9009, #8525).
                        14. Fix Find-result rclick-Copy incomplete data bug (Fix #8801).
                        15. Add case insensitive lines sorting (Implement #4479).
                        16. Add "Open Containing Folder as Workspace" command in main menu and in context menu of tabs (Implement #3028).
                        17. Enhance Sel info of status bar (Fix #8524).
                        18. Add new option for save type of normal text files in Save dialog (Fix #8866).
                        19. Fix file path truncated issue in save confirmation dialog (Fix #8812).
                        20. Fix auto-Indent not working for PowerShell (Fix #9049).
                        21. Allow setting of background color for bookmark margin (Fix #8833).
                        22. Fix smart-highlighting not applying to cloned view (Fix #7910).
                        23. Fix smart highlight issue related to EOF (Fix #8908).
                        24. Fix closing file in 2nd view not removed from Doc Switcher (Fix #8800).
                        25. Add Delete keystroke to remove selected root from Folder as Workspace (Fix #8960).
                        26. Add TAB keystroke in Function List to switch between search field and list (Fix 8665).
                        27. Add ESC keystroke in Function List to switch to edit window (Fix #8886).
                        28. Add ESC keystroke to close Search Results Window (Implement #2946).
                        29. Fix data-prefixed attributes are not recognized in HTML (Fix #6200).
                        

                        Best Regards,

                        guy038

                        A 1 Reply Last reply Dec 8, 2020, 1:59 PM Reply Quote 3
                        • A
                          Alan Kilborn @cisco779k
                          last edited by Dec 8, 2020, 1:53 PM

                          @cisco779k said in help to delete part of line:

                          how can i put a bookmark only on even lines of a list?

                          I would do it this way:

                          673a2e80-41f2-4750-8f6d-08c60a4df7cd-image.png

                          This will put red marking on the text for the first character in even lines. If you don’t like that, untick Bookmark line and press the Clear all marks button.

                          can i put a bookmark only on specific ranges of lines?

                          Yes, use In selection checkbox rather than Wrap around for this. However, note that the notion of “even” will be from the point where you start the selection, NOT the absolute line numbering.

                          1 Reply Last reply Reply Quote 2
                          • A
                            Alan Kilborn @guy038
                            last edited by Alan Kilborn Dec 8, 2020, 2:00 PM Dec 8, 2020, 1:59 PM

                            @guy038 said in help to delete part of line:

                            SEARCH (?-s)(.*\R).*\R?

                            Guy, maybe you should edit your post above to say that THIS regex solves THIS problem requested by the OP:

                            how to delete even lines in a list?

                            Because the OP asked for 3 things in one posting, it is (slightly) confusing which one you are addressing.

                            1 Reply Last reply Reply Quote 2
                            • C
                              cisco779k
                              last edited by Dec 8, 2020, 2:30 PM

                              @Terry-R
                              thank you for your support, but my problem persists at point 3 of your help (create a specific regex)…

                              @guy038
                              thank you for your regex. wonderfull, like all your regex!

                              @Alan-Kilborn
                              your contribution is also very interesting. something that can also be useful on other occasions and not only for this specific case.
                              thank you for your useful information.

                              so, people like you who know a lot about np++ help someone like me understand many aspects still unclear about this wonderful (and complex) program.
                              A DUTIFUL AND HEARTFELT THANKS TO ALL THOSE WHO HAVE CONTRIBUTED TO THIS LONG POST (in the hope that it can also help other users who, like me, do not have all your knowledge about it).

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