• Login
Community
  • Login

delete specific lines

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 3 Posters 3.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.
  • G
    Guy Przytula
    last edited by Apr 25, 2018, 1:00 PM

    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

    S 1 Reply Last reply Apr 25, 2018, 2:06 PM Reply Quote 1
    • S
      Scott Sumner
      last edited by Apr 25, 2018, 1:52 PM

      @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
      • S
        Scott Sumner @Guy Przytula
        last edited by Scott Sumner Apr 25, 2018, 2:07 PM Apr 25, 2018, 2:06 PM

        @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
        • G
          Guy Przytula
          last edited by Apr 25, 2018, 2:46 PM

          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
          • P
            PeterJones
            last edited by Apr 25, 2018, 3:39 PM

            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
            • P
              PeterJones
              last edited by Apr 25, 2018, 3:40 PM

              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
              4 out of 6
              • First post
                4/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors