libpcre binding of Emacs Lisp.
(let ((str "012-345-567"))
(when (pcre-match-string "\\A(\\d+)-(\\d+)-(\\d+)\\z" str)
(match-string 1 str))) ;; => 012
(with-temp-buffer
(insert "apple orange melon\n")
(insert "red blue green\n")
(insert "vim atom sublime\n")
(goto-char (point-min))
(let (matches)
(while (pcre-re-search-forward "^\\S+ ([^[:space:]]+)" nil t)
(push (match-string 1) matches))
(reverse matches))) ;; '(orange blue atom)
Works like string-match
.
Works like string-match-p
.
Works like looking-at
.
Works like looking-at-p
.
Works like looking-back
.
Works like re-search-forward
.
Following flags are supporeted now
ignorecase
: ignore case matching. However pcre.el is set this flag by currentcase-fold-search
multiline
: match for multiple line stringsdotall
:.
matches all charactres including newlineextended
: white space data in regexp is ignored