delete specific lines
-
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 -
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:
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.
-
@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 AllThe
^
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 -
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 -
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
-
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:
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: