Ted
Ted

Reputation: 645

How to delete lines between 2 line patterns using regex?

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++?

Upvotes: 4

Views: 1597

Answers (2)

Downgoat
Downgoat

Reputation: 14361

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

Upvotes: 0

karthik manchala
karthik manchala

Reputation: 13640

You can use the following to match:

FLAGSHARE[\s\S]*?2015

And replace with '' (empty string)

See DEMO

Upvotes: 5

Related Questions