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

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

Re: Help with regexp


From: harven
Subject: Re: Help with regexp
Date: Wed, 02 Dec 2009 21:00:04 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (darwin)

Lennart Borgman <address@hidden> writes:

> On Wed, Dec 2, 2009 at 5:56 PM, Andreas Politz <address@hidden> wrote:
>>
>> This reminds me of something else regexp related,  though fixable.
>> Navigating point inside a regexp is very painfully.
>
> How does it hurt?

That way (quoting the emacs wiki, ParenthesisMatching).

"...It should be noted that the syntax-table makes all delimiters even.
That means that a beginning parenthesis ( may match a closing bracket ] 
if the delimiters are not balanced as a whole. 
Try C-M-f on the following expression:

     (  [   )  ]

Here is a short piece of Lisp code in which such a situation occurs:

  (while
     (re-search-forward "\\(\\[[0-9]\\),\\([0-9]\\]\\)" nil t)
     (replace-match (concat (match-string 1) "." (match-string 2))))

This code replaces, e.g. [4,5] by [4.5]. Now, in the regular expression
between quotes " ", the first opening bracket [ matches the
first closing parenthesis ), whereas the last opening parenthesis (
matches the last closing bracket ]..."



reply via email to

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