0

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

Community
  • 1
  • 1
Swaroop
  • 431
  • 5
  • 15
  • Forget about whether or not it's wrong to use an editor for it -- it's probably wrong to be doing it at all! *Please* tell me you have express permission from the copyright holders... – Ben Burns May 18 '11 at 20:12
  • I think "filters out" is the wrong phrase to use :). I meant "matches" – Swaroop May 18 '11 at 20:16
  • 2
    Notepad++'s regex support is seriously lacking. As far as I know, lookahead is not supported (which you'd need for this). – Tim Pietzcker May 18 '11 at 20:16
  • Can you tell me about other editors that support lookbehind & ahead? – Swaroop May 18 '11 at 20:19
  • It doesn't matter what you're calling it - if the purpose is to remove someone else's copyright, you aught to go question yourself. – Ben Burns May 18 '11 at 20:19
  • Not trying to remove copyright. Just searching for source code that's not from my company – Swaroop May 18 '11 at 20:20
  • 1
    @Swaroop: Check out [EditPadPro](http://www.editpadpro.com). Best regex support on the market; version 7 coming out this month. And I'm not affiliated with that company. – Tim Pietzcker May 18 '11 at 20:22
  • @Tim: EditPad Pro v7 is already out. – MRAB May 19 '11 at 00:58
  • @MRAB: Hey, great (I had checked the newsfeed which hadn't mention it yet). Thanks for the heads-up, though I'll wait until the German version is released. – Tim Pietzcker May 19 '11 at 05:37

2 Answers2

2

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.

josh.trow
  • 4,861
  • 20
  • 31
1

/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.

Qtax
  • 33,241
  • 9
  • 83
  • 121