Limbo Peng <iwi...@gmail.com> writes: > I'm confused by the result of string-match: > > (string-match "[0-9]+" "abc123zzz") ;; this works, giving result: # > ("abc123zzz" (3 . 6)) > (string-match "\\d+" "abc123zzz") ;; this doesn't work, giving result: > #f > > Why isn't the "\\d+" syntax (character classes) supported?
Regular expression syntax is not standardized, and there are several different variants. The "\d" syntax for character classes is a non-standard perl extension, and is not supported by Guile. Guile supports the POSIX regexp syntax, whose character classes look like this: (string-match "[[:digit:]]+" "abc123zzz") => #("abc123zzz" (3 . 6)) For more information see: http://www.gnu.org/software/guile/manual/html_node/Regular-Expressions.html http://www.gnu.org/software/emacs/manual/html_node/emacs/Regexps.html http://www.gnu.org/software/emacs/manual/html_node/elisp/Char-Classes.html Mark