bug-gnu-emacs
[Top][All Lists]
Advanced

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

Re: 21.1 incorrect Regular expression parsing


From: David Kastrup
Subject: Re: 21.1 incorrect Regular expression parsing
Date: 10 Dec 2001 23:59:15 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

>>>>> "Jari" == Jari Aalto+mail emacs <jari.aalto@poboxes.com> writes:

 Jari> * 2001-12-09 Stefan Monnier <monnier+gnu.emacs.bug/news/@RUM.cs.yale.edu>
 Jari> * 
<http://search.dejanews.com/msgid.xp?MID=%3C5l667gw3y7.fsf@rum.cs.yale.edu%3E&format=threaded>
 >>>>>>> "Jari" == Jari Aalto+mail <jari.aalto@poboxes.com> writes:
 >> 
 >>> Following statement does not signal error. It should, because 
 >>> it is not a valid regular expression
 >>> (string-match "[0-9]++" "12")
 >> 
 Jari> | Where have you seen it documented as "not valid" ?

 Jari> I'm not sure I understand your question. If you mean that we need a
 Jari> section from POSIX documentation before, I'm afraid I cannot provide
 Jari> one. I guess the official chapter may label the behavior "undefined."

 Jari> I understand this to be a regular expressing bug and It would
 Jari> be good if Emacs signalled error.

The Emacs manual states about regular expressions:

`+'
     is a postfix operator, similar to `*' except that it must match
     the preceding expression at least once.  So, for example, `ca+r'
     matches the strings `car' and `caaaar' but not the string `cr',
     whereas `ca*r' matches all three strings.

It does not say that the preceding expression is not allowed to be a
more complicated expression, so x++ according to that interpretation
would be equivalent to x+.

We also have the passage
   Note: for historical compatibility, special characters are treated as
ordinary ones if they are in contexts where their special meanings make
no sense.  For example, `*foo' treats `*' as ordinary since there is no
preceding expression on which the `*' can act.

So if you said in x++ the second + is in a context "where their
special meanings make no sense", it would match a literal +.

The Emacs manual does not say any use of those characters is illegal.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: David.Kastrup@t-online.de



reply via email to

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