読者です 読者をやめる 読者になる 読者になる

libpcre binding of Emacs Lisp

emacs

I'm writing libpcre binding of Emacs Lisp. Most of programmers is not familiar with Emacs Lisp regular expression because regular expression function or library of many languages has compatibility of Perl regular expression. I suppose such people writes regular expression easily with this library.

Repository

github.com

Sample code

(let ((input "https://example.com/foo/bar/baz.txt")
      (regexp "
^
# backslash is not necessary for grouping
(https?): # $1 schema
//
([^/]+)   # $2 host
(/.*)     # $3 path
$
"))
  (when (pcre-string-match regexp input '(extended)) ;; extends flag allows space/comment in regular expression
    (message "schema:%s, host:%s, path:%s"
             (match-string 1 input)
             (match-string 2 input)
             (match-string 3 input)))) ;; "schema:https, host:example.com, path:/foo/bar/baz.txt"

Interfaces

https://github.com/syohex/emacs-pcre/blob/master/README.md

I design this library same as Emacs regular expression interfaces, signature, behavior etc. For example case sensitive or insensitive searching is decided by current case-fold-search value.

Issues or any suggestions

Please report me if you have any suggestions via github issue.