(defun perlish-fix-regexps (regexp) "Simple translation of a perlish REGEXP to an emacs one." (let ( (new-pattern regexp) ) (setq new-pattern (replace-regexp-in-string "(" "\\\\(" new-pattern)) (setq new-pattern (replace-regexp-in-string ")" "\\\\)" new-pattern)) (setq new-pattern (replace-regexp-in-string "|" "\\\\|" new-pattern)) (setq new-pattern (replace-regexp-in-string "\\\\\"" "\"" new-pattern)) new-pattern)) (perlish-fix-regexps "(.*?)") (perlish-fix-regexps "(ha|ho)") (perlish-fix-regexps "\"[ \t]*(.*?)[ \t]*\"") (defun perlish-match (string pattern) "Apply the perlish PATTERN to STRING, returns capture from first group of parens." (let ( (emacs-pattern (perlish-fix-regexps pattern)) (found "") ) (if (string-match emacs-pattern string) (setq found (match-string 1 string)) ) )) (perlish-match "ha, ha, ho, ho!" "(ha|ho)" ) (perlish-match " \" quote \" " "\"[ \t]*(.*?)[ \t]*\"")