How do I remove lines of text before this character?

5,688
  • Ctrl+H
  • Find what: ^.*(?====)
  • Replace with: LEAVE EMPTY
  • check Wrap around
  • check Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

^           # beginning of line
  .*        # 0 or more any character but newline
  (?=       # positive lookahead, make sure we have after:
    ===     # 3 equal sign
  )         # end lookahead

Result for given example:

[email protected]:948
===
[email protected]:123

Screen capture (before):

enter image description here

Screen capture (after):

enter image description here

Share:
5,688

Related videos on Youtube

chalbrak
Author by

chalbrak

Updated on September 18, 2022

Comments

  • chalbrak
    chalbrak over 1 year

    Let's say I have this little text file, for example reasons.

    [email protected]:948
    [email protected]:11111===
    [email protected]:123
    

    How would I remove all the text before ===?

    I use Windows 10 so no need for anything about Linux.

    • Seth
      Seth over 4 years
      Select them and press either Backspace or Delete.
    • JW0914
      JW0914 over 4 years
      A general FYI that's off-topic, but wanted to share from my own experience: You may want to look at VS Code in lieu of Notepad++ for a variety of reasons, but mainly due to Notepad++ having almost non-existent community development, lack of themes and true dark theme support, a myriad of untrusted plugins, etc.
    • Anaksunaman
      Anaksunaman over 4 years
      VS Code is arguably overkill for general text editing, especially since it can be extremely resource intensive for what should be simple, low-cost operations like text replacement/removal.
  • chalbrak
    chalbrak over 4 years
    i have a newer version of np++, how do i change the direction?
  • lakshman
    lakshman over 4 years
    what is the version you are using?
  • chalbrak
    chalbrak over 4 years
    7.7.1, i'm not sure what to do
  • lakshman
    lakshman over 4 years
    If it has backward direction checkbox, untick it
  • chalbrak
    chalbrak over 4 years
    i unchecked backward direction, copy and pasted everything, left replace with empty, put in your code in the find what section, used regular expression and selected the space before the first character and nothing happened
  • chalbrak
    chalbrak over 4 years
    thanks, but i also wanted it to be that it removes all of the text before it (including the previous lines eg. thisisanexample)
  • Toto
    Toto over 4 years
    @Your question wasn't clear. Change Find what: \A.*(?====) and Check . matches newline. Ths will remove ALL lines from the beginning of the file until === If this doesn't work as expected, please, edit your question and add sample lines and expected result.