Bart の回答とすべてのコメントに感謝します。Bart's に触発されて、emacs がまだ先読みをサポートしていないように見えることを確認しました。しかし、その精神で、私は次のようにコーディングしました。
(defun string-match-but-exclude (正規表現文字列の除外 &optional start)
「文字列の正規表現の最初の一致の開始のインデックスを返すか、nil を返しますが、除外で正規表現を除外します。match case-fold-search' is non-nil.
If third arg start is non-nil, start search at that index in string.
For index of first char beyond the match, do (match-end 0).
-end」と「match-beginning」がパターン内の括弧構造によって一致する部分文字列のインデックスも与える場合、一致は大文字と小文字を区別しません.
関数 `match-string' を使用して、正規表現の括弧構造に一致する部分文字列を抽出できます。"
(let ((データ nil))
(and (string-match regexp string start)
;; keep the match-data for recovery at the end.
(setq data (match-data))
(not (string-match (concat "[" exclusion "]") (match-string 0 string)))
(progn (set-match-data data) t) ; To recover the match data, and make sure it produces t as returned value
(match-beginning 0)
))
)
したがって、 (?!')[[:punct:]] 文字列 "'") の同等の式については
それはそのようになります
(string-match-but-exclude "[[:punct:]]" string "'")
これは仕事をしますが、エレガントではありません。これを組み込みサポートにするために、emacs にマイナーな追加を行う必要があります。
現在、emacs は文字クラスをサポートしています。
再度、感謝します。
ゆう