Swaroop
Swaroop

Reputation: 441

regular expression for skipping specific words

I need to make a regular expression (I'm using notepad++ for searching text files) that matches all copyright lines without my company name:

// Copyright MyCompany

// Copyright OtherCompany

// Copyright OtherCompany2

It should match the second line & third line but not the first line. Is this possible at all? (I've seen the discussion here: Regular Expression to exclude set of Keywords but it doesn't seem to work in notepad++. Also, is it wrong to be using an editor for this?)

Upvotes: 0

Views: 270

Answers (2)

Qtax
Qtax

Reputation: 33908

/Copyright[ \t]++(?!MyCompany)/i

Would be the regex, but don't think that notepad++ has support for such regexes. If you install Perl you can use that regex with a one liner.

Upvotes: 1

josh.trow
josh.trow

Reputation: 4901

I would suggest getting Cygwin if you are on Windows, otherwise just use the command line and go with

grep 'Copyright' theFile.txt | grep -v 'MyCompanyName' > theParsedFile.txt

EDIT: Modified to answer the question better.

Upvotes: 2

Related Questions