all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Subject: short regexp to match any character?
Date: Sat, 4 Mar 2006 10:34:16 -0800	[thread overview]
Message-ID: <MEEKKIABFKKDFJMPIOEBKEKLCPAA.drew.adams@oracle.com> (raw)

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	other threads:[~2006-03-04 18:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-04 18:34 Drew Adams [this message]
2006-03-11 22:07 ` short regexp to match any character? Juri Linkov
2006-03-12  0:30   ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MEEKKIABFKKDFJMPIOEBKEKLCPAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.