emacs-devel
[Top][All Lists]
Advanced

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

short regexp to match any character?


From: Drew Adams
Subject: short regexp to match any character?
Date: Sat, 4 Mar 2006 10:34:16 -0800

For input (typing) purposes, what is the shortest (or a fairly short and
simple) Emacs regexp that will match what this regexp matches: \(.\|[\n]\)
(where the [\n] would be `C-q C-j' interactively)?

[[:print:]] does about the same thing. In practice, something like [^^G]
(any character except control-G) does the job much of the time. But I wonder
if there is a simple, short regexp that will match what . matches plus
newline?

Some languages, like perl, have a "doc-matches-newline" mode (aka
"single-line" mode) where . will also match newline. I guess Emacs does not
have such a mode. Should it? Should it have a variable/option that, when
bound to non-nil, lets . match newlines too? (Does it already?)

I'm thinking of regexp input to commands, where things like .* can be common
to match any sequence of characters. If you have an input regexp like
foo.*bar.*toto, it can sometimes be useful to let . match newlines too (e.g.
when matching against a doc string or other multi-line text). Without that
possibility, the regexp becomes more cumbersome and less readable:
foo\(.\|^Q^J\)*bar\(.\|^Q^J\)*toto.

Emacs uses regexps interactively more than most apps, and many (most) Emacs
users are programmers who are familiar with regexps. Regexps can serve as
input to apropos, occur, and other commands, in addition to being used for
searching.

I'm thinking it would help Emacs users to make it easy (short) to match any
character, including newline. Am I missing something that's already there?
If not, would this be a useful feature to add?





reply via email to

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