Notepad++ RegEx delete line starting with \pard.....ending with line feed

10,533
\\pard.*(\r)?\n

The question mark after the repeater is so that it isn't greedy or it will swallow most of the file including the parts it shouldn't...

Editted: Now it should handle line breaks properly

Edit: Try this

^\\pard.*$
Share:
10,533
Sarah
Author by

Sarah

Updated on June 04, 2022

Comments

  • Sarah
    Sarah almost 2 years

    I'm cleaning up files using Notepad ++, and trying to delete lines that start with \pard and have some text then end with a line feed. But \n doesn't work in RegEx and .* doesn't work in an extended find and replace.

    This is what I've tried unsuccessfully: \pard.*\n

    \pard.* works but leaves the line feed in RegEx.

  • BoltClock
    BoltClock over 13 years
    Notepad++ does not recognize greedy/ungreedy modifiers.
  • Alan Moore
    Alan Moore over 13 years
    The problem isn't the carriage return, it's Notepad++ itself. NPP's "Regular Expression" search mode works on one line at a time--it actually strips off the line separators before applying the regex. And its "Extended" mode supports several kinds of escapes including \n, \r, etc., but has none of the other features associated with regexes (or even globs). There's no way to combine the two modes; as the OP said, you can have line separators or regexes, but not both.
  • J V
    J V over 13 years
    No I know theres a way, I used to use it all the time (Before I switched to linux) Try the new one...
  • Alan Moore
    Alan Moore over 13 years
    Nope! ^\\pard.*$ works in NPP like like it does in any other flavor: it finds the correct line, but the match doesn't include the line separators (leading or trailing). Maybe you're thinking of the "Find All/Delete Bookmarked Lines" trick from that other thread Cameron linked to. Or a plugin.
  • Sarah
    Sarah over 13 years
    Thanks for all the interest, unfortunately I had to complete the task somewhat manually and no longer have the files to trial your suggestions. Thanks again.
  • J V
    J V over 13 years
    Perhaps replace would work if you used "select all" first, either way, npp seems to be a pita, I'd just open it in something more robust.