Next: 7.5 編集用関数
Up: 7 Emacsの基本編集関数
Previous: 7.3 文字種スキップ
バッファの中で正規表現rexpを検索する関数として,re-search-forwardで
検索をした後,match-beginning, match-endはそのマッチした
文字列の場所を返す.match-beginningの引数は,
0だとrexp文字列全体の場所を返し,1以上の数だと
rexp内の探索グループ文字のインデックスになる.
文字列を与えて正規表現rexpを検索する関数としてstring-matchがある.
検索移動関数 |
(re-search-forward rexp limit error count) |
バッファの中で正規表現で
探索を行う |
(re-search-backward rexp limit error count) |
バッファの中で正規表現で
探索を行う |
(string-match rexp string start) |
文字列の中の正規表現探索を行う |
(looking-at rexp) |
ポイント位置以降が正規表現にマッチするかどうかを判定 |
(match-beginning gnum) |
グループ番号gnumの先頭のポイント値 |
(match-end gnum) |
グループ番号gnumの末尾のポイント値 |
(buffer-substring begin end) |
|
(save-match-data form) |
|
(match-data) |
|
(store-match-data data) |
|
たとえば,string-matchに対する,match-string
が返すものはつぎのようになる.
(string-match "\\(qu\\)\\(ick\\)"
"The quick fox jumped quickly.")
;0123456789
4
(match-string 0 "The quick fox jumped quickly.")
"quick"
(match-string 1 "The quick fox jumped quickly.")
"qu"
(match-string 2 "The quick fox jumped quickly.")
"ick"
(match-beginning 1) ; The beginning of the match
4 ; with `qu' is at index 4.
(match-beginning 2) ; The beginning of the match
6 ; with `ick' is at index 6.
(match-end 1) ; The end of the match
6 ; with `qu' is at index 6.
(match-end 2) ; The end of the match
9 ; with `ick' is at index 9.
さらに,re-search-forwardに対するmatch-beginning
が返す例としては次のようになる.
(list
(re-search-forward "The \\(cat \\)")
(match-beginning 0)
(match-beginning 1))
) (9 9 13)
---------- Buffer: foo ----------
I read "The cat ?in the hat comes back" twice.
^ ^
9 13
---------- Buffer: foo ----------
マーカー操作用関数 |
(make-marker) |
マーカーオブジェクトを作成 |
(set-marker marker point) buffer) |
マーカをpoint値に設定 |
(point-marker) |
現ポイントを指すマーカオブジェクトを作る |
(marker-position marker) |
マーカ位置のポイント値を数として返す |
(integer-or-marker-p) |
引数が数値かマーカであるかを返す |
(narrow-to-region pos1 pos2) |
編集可能領域をpo1,pos2の間に移す |
(widen) |
ナローイングを解除し,バッファのすべての範囲にアクセスできるよ
うにする |
(save-restriction form) |
formを評価し,評価後ナローイングを元に戻す |
Next: 7.5 編集用関数
Up: 7 Emacsの基本編集関数
Previous: 7.3 文字種スキップ
generated through LaTeX2HTML. M.Inaba 平成18年5月7日