Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    delete specific lines

    Help wanted · · · – – – · · ·
    3
    6
    3169
    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.
    • Guy Przytula
      Guy Przytula last edited by

      i am using notepad 756 on windows
      Is there a possibility to say :
      I want to delete all lines : that start with – (2 dashes)

      or to say
      I want to delete lines between :
      line that starts with CREATE… and
      line that keeps ;
      Thanks for all info/help
      Best Regards, Guy

      Scott Sumner 1 Reply Last reply Reply Quote 1
      • Scott Sumner
        Scott Sumner last edited by

        @Guy-Przytula

        Probably can be done. But who can say from the way you’ve described it… Why don’t you show some actual data here so that what you want is perfectly clear? The best way to do it is like this when you are composing your post:

        Imgur

        If you do it like the above (note the first line with the 3 backticks and the z, and the last line with the 3 backticks), then it will post as follows:

        my lines between these 
        2 delimiting lines will not
        be specially interpreted
        by this website.
        
        1 Reply Last reply Reply Quote 1
        • Scott Sumner
          Scott Sumner @Guy Przytula last edited by Scott Sumner

          @Guy-Przytula said:

          I want to delete all lines : that start with – (2 dashes)

          So that part is clear at least.

          Try:

          Find what zone: ^--[^\r\n]*\R
          Replace with zone: make sure this is empty
          Search mode: Regular expression
          Action: Replace or Replace All

          The ^ means make sure we are at start of line
          The part inside [ and ]* means match any number of characters that are not a line ending
          The \R part means to match a line-ending

          1 Reply Last reply Reply Quote 1
          • Guy Przytula
            Guy Przytula last edited by

            thanks for the update
            the first part : delete lines that start with – : tried it and ok
            for the second part :
            I have lines like :
            CREATE TABLE …
            (NOPOL CHAR(6) NOT NULL,
            AVTAUT CHAR(2) NOT NULL,
            … multiple line
            IN DDU00P1.SDU011 ;
            the block of lines start with : CREATE TABLE
            the block ends with : … ;
            all lines including start/end should be deleted…
            thanks for all update/help
            best regards, Guy

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

              Using the same setup as Scott used, change to

              Find what : ^CREATE TABLE[^;]*;\R

              • ^CREATE TABLE: first line to match must start with CREATE TABLE
              • [^;]*: match as many characters that aren’t semicolon as you can (including EOL)
              • ;: followed by single semicolon
              • \R: followed by end of line

              If there might be whitespace before the CREATE TABLE or after the semicolon
              Find what : ^\s*CREATE TABLE[^;]*;\s*\R

              • \s*: finds zero or more whitespace characters
              1 Reply Last reply Reply Quote 0
              • PeterJones
                PeterJones last edited by

                P.S. :
                (paraphrasing @guy038, the forum’s regex guru, who compiled these great regex resources, but hasn’t shared them in this thread yet):

                Here is a good starting point for NPP users unfamiliar with regular expression concepts and syntax:

                • http://docs.notepad-plus-plus.org/index.php/Regular_Expressions

                Modern Notepad++ (since v6.0) uses the Boost C++ Regex library, v1.55.0 (similar to the Perl Regular Common Expressions (PRCE), v5.8):

                • search syntax: http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
                • replace syntax: http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html

                Other sites with valuable regular expression information include:

                • http://perldoc.perl.org/perlre.html
                • http://www.regular-expressions.info
                • http://www.rexegg.com
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Copyright © 2014 NodeBB Forums | Contributors