* short regexp to match any character?
@ 2006-03-04 18:34 Drew Adams
2006-03-11 22:07 ` Juri Linkov
0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2006-03-04 18:34 UTC (permalink / 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?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: short regexp to match any character?
2006-03-04 18:34 short regexp to match any character? Drew Adams
@ 2006-03-11 22:07 ` Juri Linkov
2006-03-12 0:30 ` Drew Adams
0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2006-03-11 22:07 UTC (permalink / raw)
Cc: emacs-devel
> 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?
I think this feature could be implemented by analogy with
search-spaces-regexp and search-whitespace-regexp, i.e.
after setting a new variable `search-dot-regexp' to "\\(.\\|[\\n]\\)",
`.' would match newlines too.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: short regexp to match any character?
2006-03-11 22:07 ` Juri Linkov
@ 2006-03-12 0:30 ` Drew Adams
0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2006-03-12 0:30 UTC (permalink / raw)
> 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?
I think this feature could be implemented by analogy with
search-spaces-regexp and search-whitespace-regexp, i.e.
after setting a new variable `search-dot-regexp' to "\\(.\\|[\\n]\\)",
`.' would match newlines too.
Yes, and it would be good to have a key (perhaps `C-.') bound in the Isearch
map to toggle the newline sensitivity of dot (just like toggling case
sensitivity. That way, when searching, you could change the value of
`search-dot-regexp' on the fly.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-03-12 0:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-04 18:34 short regexp to match any character? Drew Adams
2006-03-11 22:07 ` Juri Linkov
2006-03-12 0:30 ` Drew Adams
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.