guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: regexp character classes not supported?


From: Mark H Weaver
Subject: Re: regexp character classes not supported?
Date: Fri, 28 Dec 2012 12:22:19 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Limbo Peng <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]