0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[スニペット] 正規表現

Posted at

条件
[ ](空の角括弧)は除外
[1a2wh3]のように、角括弧の中に何らかの英数字が含まれているパターンの行を抽出

grep -E '\[[^]]+[[:alnum:]][^]]*\]' ファイル名

解説:
-E:拡張正規表現(ERE)を使うためのオプション(egrepでも同じ)
[:リテラルの左角括弧([)を意味
[^]]+:右角括弧以外の文字を1文字以上 → ] で閉じる前に何かが入っている
[[:alnum:]]:英数字(A-Z, a-z, 0-9)1文字を含む
[^]]*:残りの部分で ] 以外の文字が0文字以上続く
]:リテラルの右角括弧(])

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?