开发者

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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜