タグ付き正規表現で置換
タグ付き正規表現は、一度使用した正規表現を繰り返し使いたいときに使用します。
sed, awk, emacs, grep, egrepなどがタグ付き正規表現が使えます。
使いかたは
例は次の様になります。
次のような文章があり、先頭の";; "を除去したいときタグ付き正規表現を使用し置換する。
;; This buffer is for notes you don't want to save, and for Lisp evaluation. ;; If you want to create a file, visit that file with C-x C-f, ;; then enter the text in that file's own buffer.
次の正規表現で置換する。emacsではreplce-regexp, sed, awkでも同様に使える。
置換前 ^;; \(.*\) 置換後 \1
実行結果は次の様になります。
This buffer is for notes you don't want to save, and for Lisp evaluation. If you want to create a file, visit that file with C-x C-f, then enter the text in that file's own buffer.