0 はじめに
- サクラエディタで何かのファイルを開いて、
正規表現を使って文字を置換する場合の色々なメモです。
サクラエディタで使える基本的な正規表現についてはgithubの公式サイトがある
パターン1 空行を削除する
パターン2 文字列を複数検索
パターン3 VBAのソースの中で空行、改行、コメントアウト以外を取得
パターン4 VBAのソースの中でコメントアウト行を取得
パターン5 Grepの正規表現
common2015-10-05-11-44.log
test
aaaa
test
common2015-11-22-10-34.log
errerwrwe
test
fsdfafa
common2015-12-01-11-44 .log
rrrrr
dfsfsdfasftest
test
sadfadfadfatestfgsfgsgsdg
④Grep検索結果
パターン1
検索条件 "test"
検索対象 common2015-10*.log common2015-11*.log common2015-12*.log
フォルダ C:\kaihatsu\02_sakuraEditor\grep
(サブフォルダも検索)
(英大文字小文字を区別しない)
(正規表現:bregonig.dll Ver.3.06 with Onigmo 5.15.0)
(文字コードセットの自動判別)
(一致した行を出力)
C:\kaihatsu\02_sakuraEditor\grep\common2015-10-05-11-44.log(1,1) [SJIS]: test
C:\kaihatsu\02_sakuraEditor\grep\common2015-10-05-11-44.log(6,1) [SJIS]: test
C:\kaihatsu\02_sakuraEditor\grep\common2015-11-22-10-34.log(3,1) [SJIS]: test
C:\kaihatsu\02_sakuraEditor\grep\common2015-12-01-11-44 .log(4,11) [SJIS]: dfsfsdfasftest
C:\kaihatsu\02_sakuraEditor\grep\common2015-12-01-11-44 .log(7,1) [SJIS]: test
C:\kaihatsu\02_sakuraEditor\grep\common2015-12-01-11-44 .log(10,12) [SJIS]: sadfadfadfatestfgsfgsgsdg
6 個が検索されました。
パターン2
検索条件 "test"
検索対象 common2015-(10|11|12)-(05|22|11).*log
フォルダ C:\kaihatsu\02_sakuraEditor\grep
(サブフォルダも検索)
(英大文字小文字を区別しない)
(正規表現:bregonig.dll Ver.3.06 with Onigmo 5.15.0)
(文字コードセットの自動判別)
(一致した行を出力)
0 個が検索されました。
パターン6 番号から始まる文の前に★を挿入する
パターン7 HTMLタグで囲まれた文字の部分だけ取得
^\s*
< .* >\r\n \r\n
^\s*(\r\n|\r|\n)
パターン8 先頭が#1、#2、#10、#11とかなっているところを# 1、# 2、# 3、# 10、みたいに#と数字の中に半角スペースを挿入する
パターン9 年号Y年MM年DD日を検索する方法
パターン10 先頭が#、##、###、####とかなっているところを# 、## 、### 、#### 、みたいに#の後に半角スペースを挿入する
パターン11 グループ化の置換 ,E,もしくは,C,になっていたら2に置換する
3333,111,E,2222,C,wwwww
3333,111222222wwwww