70
47

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

特定の文字を含まない行を削除する

Last updated at Posted at 2016-04-25

良く使うのでメモ。
EclipseやAtom等、正規表現の 否定先読み が使える場合、以下の正規表現置換で出来ます。

Emacs以外は大体出来るきがする...

やり方

XXX を含まない行を消してみます。
各Editorで置換する時に以下の置換対象/置換後を指定します。

置換対象 (正規表現):

^(?!.*XXX).*\r\n

置換後:

(空欄)

Macはこう

^(?!.*XXX).*\n

改行 \n は正規表現の記法ではないので、OS/Editorによってまちまち。

  • Windows
    • ^(?!.*XXX).*\r\n
  • Mac
    • ^(?!.*XXX).*\n
  • Eclipse
    • ^(?!.*XXX).*\R
    • \R はPlatform independentな改行を表すEclipseの特殊文字.
70
47
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
70
47

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?