Find term and delete the line above
-
Hi everyone!
First of all, I’m very noob…So I need to delete a specific line, the content changes, but is always above a specific term, I made the following test and the result is what I want, but on NP++ seems not work:
I need to do it on several files, something like 2k, but is not working even on single file.
Sorry my bad english and thanks in advance!
-
@Watashi ,
it would have been nice to embed the sample text and sample regex
(?:.*\n){1} End Object
in your post, rather than making us follow an external link.... defaultproperties { ... ... way too much text, that's completely irrelvant... Name="SpriteEmitter1" End Object ... }
But when I put in that FIND, it finds one occurrence:
– but it appears that it’s only selecting the EOL through the next line.Oh, wait, your regex just has
\n
. If you’re in windows, the EOL marker is\r\n
. Unless you have. matches newline
enabled (or(?s)
in the regex), the.*
will not match\r
or\n
. So.*\n
then can only match a zero-width.*
followed by the\n
before the line you’re really looking for.If you have normal Windows EOL shown in your status bar, , then you need to look for
\r\n
… or, to be able to handle different file types,\R
will match\r
,\n
, or\r\n
.So change your regex to
(?:.*\R){1} End Object
. In my experiment, that removed the specific line before theEnd Object
lineAlso, as regex101 told you, the
{1}
was useless (unless that’s just a simplified version of your search-regex, and really you are capturing multiple lines before theEnd Object
). -
@PeterJones Sorry about the link, I’ll keep that in mind for the next time!
Oh, you’re right, {1} is not needed for single line :O
“Not every hero wears a cape” =D
Did work like a charm * – *
Thank You so much!