GNU bug report logs - #12665
regexp fault for closing square bracket within character class

Previous Next

Package: guile;

Reported by: Panicz Maciej Godek <godek.maciek <at> gmail.com>

Date: Wed, 17 Oct 2012 19:59:01 UTC

Severity: normal

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12665 in the body.
You can then email your comments to 12665 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#12665; Package guile. (Wed, 17 Oct 2012 19:59:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Panicz Maciej Godek <godek.maciek <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Wed, 17 Oct 2012 19:59:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Panicz Maciej Godek <godek.maciek <at> gmail.com>
To: bug-guile <at> gnu.org
Subject: regexp fault for closing square bracket within character class
Date: Wed, 17 Oct 2012 21:33:58 +0200
guile 2.0.5-deb+1-1
(string-match "[\\[]" "[")
===> #("[" (0 . 1))
(string-match "[\\]]" "]")
===> #f




Reply sent to Mark H Weaver <mhw <at> netris.org>:
You have taken responsibility. (Thu, 18 Oct 2012 04:56:02 GMT) Full text and rfc822 format available.

Notification sent to Panicz Maciej Godek <godek.maciek <at> gmail.com>:
bug acknowledged by developer. (Thu, 18 Oct 2012 04:56:02 GMT) Full text and rfc822 format available.

Message #10 received at 12665-done <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: Panicz Maciej Godek <godek.maciek <at> gmail.com>
Cc: 12665-done <at> debbugs.gnu.org
Subject: Re: bug#12665: regexp fault for closing square bracket within
	character class
Date: Thu, 18 Oct 2012 00:54:01 -0400
Panicz Maciej Godek <godek.maciek <at> gmail.com> 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




Information forwarded to bug-guile <at> gnu.org:
bug#12665; Package guile. (Thu, 18 Oct 2012 09:47:02 GMT) Full text and rfc822 format available.

Message #13 received at 12665-done <at> debbugs.gnu.org (full text, mbox):

From: Panicz Maciej Godek <godek.maciek <at> gmail.com>
To: Mark H Weaver <mhw <at> netris.org>
Cc: 12665-done <at> debbugs.gnu.org
Subject: Re: bug#12665: regexp fault for closing square bracket within
	character class
Date: Thu, 18 Oct 2012 11:44:30 +0200
> 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 `-'.

OK, I see. I guess I got used to PCRE for too long :)
Sorry for my mistake.

Regards




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 15 Nov 2012 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 269 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.