LoginSignup
3
4

More than 3 years have passed since last update.

正規表現の記号一覧

Last updated at Posted at 2020-10-20

正規表現の記号一覧

記号 意味
| or
[] range
^ not include
* zero or more
? zero or one
+ one or more
. any one
^ leading
$ trailing
\ backreference
{} specific amount
\s space

not includeの ^[] 内の全文字にかかります。
* ? + は直前の文字にかかります。

全ての/を\/に置換する
sed 's/\//\\\//g'
カレントディレクトリのフルパスを削除する
sed -E "s/$(pwd|sed 's/\//\\\//g')\///"

ファイル名のフルパスからファイル名を抜き出すときに使います。

ダブルクォーテーション内の文字列を\1に抽出する
sed 's/^.*"\(.*\)".*$/\1/'
全ての4桁の数字の上2桁を削除する
sed 's/\([0-9][0-9]\)\([0-9][0-9]\)/\2/g'

参考リンク

3
4
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
3
4