[Top][All Lists]

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

Re: bug in elisp... or in elisper???

From: Kevin Rodgers
Subject: Re: bug in elisp... or in elisper???
Date: Thu, 24 Mar 2011 21:44:36 -0600
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv: Gecko/20110303 Thunderbird/3.1.9

On 3/23/11 8:18 AM, ken wrote:
You might have noticed I use "\\([\s-\\|\n]+?\\)" to non-greedily match
one or more whitespace characters.  Can one "\\[...\\] be nested inside
another...?  e.g., "[[\s-\\|\n]+?]" or some syntax like that?


It is not clear whether you mean "\s" (space) followed by "-" (which is
special within "[]"), or you actually meant "\\s-" (i.e. any character
with whitespace syntax).  The problem with "\\s-" is that it depends on
the buffer's syntax table, as does "[[:space:]]" -- see section
(Character Classes) in the Emacs Lisp manual for an explanation of
"[[:space:]]" and other POSIX-inspired character classes:

If you are going to add "\n" to "\\s-" or "[:space:]", within "[]" or
"\\(\\|\\)", because you can't be sure whether the buffer's syntax table
assigns whitespace syntax to newline, then how can you be sure that it
assigns whitespace syntax to space, tab, formfeed, return, and vertical

So you may as well be explicit about what you mean by whitespace e.g.
"[ \f\t\n\r\v]"

The "specialness" of "." seems to be lost when inside brackets; that is,
in "[.\n]*?" it seems to represent a regular period (.) rather than "any
character except newline".  Is there some way to bring back that
specialness?  Or is there some other RE to represent "multiple instances
of any character, including a newline"?

No, inside "[]", "." is not special.

The right way is: "\\(.\\|\n\\)*"

There may be other ways, but they will be longer and unnecessarily complex.

Is it actually true (what the docs say) that there's a limit of nine
sub-expression match-strings per RE?  Or can I do, e.g., "(match-string
12)" and "(match-string 15)"?  What is the actual limit?  Whatever it
is, is this hard-coded into elisp... or can it be changed/configured to
something else?

No, but you can only refer to the first 9 sub-expressions (actually, the
text matched by each of the first 9 preceding sub-expressions).

Kevin Rodgers
Denver, Colorado, USA

reply via email to

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