Article View: gnu.emacs.help
Article #188865Re: Newlines in regexps
From: Gabriel
Date: Sun, 26 May 1991 01:37
Date: Sun, 26 May 1991 01:37
38 lines
2518 bytes
2518 bytes
I seem to be having a little trouble with regexps that require newlines. Say for example I want to convert standard quotes (like "arglebarge") into TeX-style quotes (like ``arglebarge''), but where the quote can span one ore more lines. I've tried things like regexp-replacing "\(\(^J\|.\)*\)" with ``\1'', but the newline seems to cause problems. Of course, to get the newline I have to use quoted-insert, but when I enter it it clears the minibuffer (but it still gets inserted into the regexp). But the above regexp still doesn't work! This is an interesting problem. I fiddled with it a bit. At first I thought it was a problem with two parenthesized expressions within one another, but it turns out that's not it. The problem is that regexps match as far as they can go; i.e., .* doesn't match "f", it matches "foobarbaz" until the next newline. So, your regexp says match a double quote, then ANY characters until the next double quote. But, "ANY characters" includes a double quote! So, that regexp will match from the first double quote to the last double quote in the buffer. So, I thought, try `[^"]' instead of `.'; but, since complement character sets include newlines, you can just use "\([^"]+\)" I guess what I am really asking is: is there an easy way to put newlines in regexps? No, and this is a problem. I've always thought that emacs regexps should have a special character that matches ALL chacters, including newlines. Not having this makes writing certain regexps cumbersome. -- Raul Acevedo acevedo@athena.mit.edu "Remember, Information is not knowledge; Knowledge is not Wisdom; Wisdom is not truth; Truth is not beauty; Beauty is not love; Love is not music; Music is the best." - Frank Zappa
Technical Details
Message-ID:
<ACEVEDO.91May25213659@tailgunner.mit.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!decwrl!deccrl!bloom-beacon!bloom-picayune.mit.edu!athena.mit.edu!acevedoReferences:
<DSMITH.91May25125350@spam.ua.oz.au>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103b8b,4118438ef0f66e70 X-Google-Attributes: gid103b8b,public X-Google-ArrivalTime: 1991-05-28 10:55:12 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!decwrl!deccrl!bloom-beacon!bloom-picayune.mit.edu!athena.mit.edu!acevedo From: acevedo@athena.mit.edu (Gabriel) Newsgroups: gnu.emacs.help Subject: Re: Newlines in regexps Message-ID: <ACEVEDO.91May25213659@tailgunner.mit.edu> Date: 26 May 91 01:37:04 GMT References: <DSMITH.91May25125350@spam.ua.oz.au> Sender: news@athena.mit.edu (News system) Distribution: gnu Organization: Massachusetts Institute of Technology Lines: 38 In-Reply-To: dsmith@spam.ua.oz.au's message of 25 May 91 03:23:50 GMT