Subject: bug#12665: closed (Re: bug#12665: regexp fault for closing square bracket within character class)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 18 Oct 2012 04:56:02 +0000

Your bug report

#12665: regexp fault for closing square bracket within character class

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
12665: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12665
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#12665: regexp fault for closing square bracket within character class
From: Mark H Weaver <[email-masked]>
To: Panicz Maciej Godek <[email-masked]>
Cc: [email-masked]
Date: Thu, 18 Oct 2012 00:54:01 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Panicz Maciej Godek <[email-masked]> writes:
> guile 2.0.5-deb+1-1
> (string-match "[\\[]" "[")
> ===> #("[" (0 . 1))
> (string-match "[\\]]" "]")
> ===> #f

As documented in "Syntax of Regular Expressions" of the Emacs manual
(to which section 6.15 of the Guile manual refers):

     To include a `]' in a character set, you must make it the first
     character.  For example, `[]a]' matches `]' or `a'.  To include a
     `-', write `-' as the first or last character of the set, or put
     it after a range.  Thus, `[]-]' matches both `]' and `-'.

For example:

  (string-match "[]\\]" "]")   ==>  #("]" (0 . 1))

Note that backslash is also a member of this character class, and of the
character class in your first example:

  (string-match "[]\\]" "\\")  ==>  #("\\" (0 . 1))
  (string-match "[\\[]" "\\")  ==>  #("\\" (0 . 1))

You might have been thinking that the backslash would escape the square
brackets in your class, but that's not how it works within character
classes.  '[' can be included anywhere in a character class without
being escaped, and ']' and '-' are handled as described above.

    Regards,
      Mark

Subject: regexp fault for closing square bracket within character class
From: Panicz Maciej Godek <[email-masked]>
To: [email-masked]
Date: Wed, 17 Oct 2012 21:33:58 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

guile 2.0.5-deb+1-1
(string-match "[\\[]" "[")
===> #("[" (0 . 1))
(string-match "[\\]]" "]")
===> #f