4

So I have a file like:

    FLAGSHARE
    xxxxxx
    xxxxx, 1 2015

    words....

    FLAGSHARE
    xxxxxx
    xxxxx, 2 2015

    words....

    FLAGSHARE
    xxxxxx
    xxxxx, 3 2015

    words....

etc.etc.

How would I be able to delete the three lines FLAGSHARE, xxxxxx, xxxxx, * 2015 (essentially remove FLAGSHARE, 2015 and lines between FLAGSHARE and 2015) using Notepad++?

2 Answers 2

5

You can use the following to match:

FLAGSHARE[\s\S]*?2015

And replace with '' (empty string)

See DEMO

Sign up to request clarification or add additional context in comments.

3 Comments

With this pattern if FLAGSHARE is followed by for example 2013, it will remove all the lines until 2015 is found. regex101.com/r/rR1wP0/1
@CasimiretHippolyte you are right.. if OP has cases like that.. I will update the answer :)
I had the same use case. I wanted to delete some code from a file which is generated dynamically.
0

You can also use:

FLAGSHARE[\S\s]*?\d{4}

DEMO

Which will also match any year

You could also use:

FLAGSHARE[\S\s]*?20\d{2}

For any year int he format: 20**

Or even:

FLAGSHARE[\S\s]*?\d\s*\d\n

Which will work in all situations

DEMO

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.