Daniel Ellison
Daniel Ellison

Reputation: 1349

Notepad ++ How to remove all characters before and after a word

I'm using regular expression in Notepad++, trying to delete everything after and before a particular word.

For example here is my text:

    blah blah Bull01 
    Bull02 Blah blah
    Bull03 Blah
    Blah Bull04
    Bull05 Blah
    blah blah Bull01 
    Bull02 Blah blah
    Bull03 Blah
    Blah Bull04
    Bull05 Blah
    blah blah Bull01 
    Bull02 Blah blah
    Bull03 Blah
    Blah Bull04
    Bull05 Blah

Im trying to delete everything before and after the word Bull, so that my results ends up being just Bull.

I tried many ways to do this using regex using something like (?<=Bull).* works for clearing anything after but cant get the formula to clear before.

Would anyone have any idea?

Upvotes: 1

Views: 1008

Answers (1)

Lars Fischer
Lars Fischer

Reputation: 10149

Maybe I don't understand your full problem, but did you try replacing .*Bull.* with Bull ?

The replacement with Bull removes everything except Bull on lines containing the word Bull.

Upvotes: 3

Related Questions