[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using non-Emacs regexp syntax
From: |
Jari Aalto |
Subject: |
Re: using non-Emacs regexp syntax |
Date: |
29 Nov 2006 22:53:22 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 |
Paul Pogonyshev <address@hidden> writes:
> David Kastrup wrote:
> > "Drew Adams" <address@hidden> writes:
> >
> > >> Is there a function to convert non-Emacs regexps (e.g. "ab(c+|d)" to
> > >> Emacs regexps (example to "ab\(c+\|d\)")?
> > >>
> > >> The first form appears to be an "extended regexp" or egrep-style regexp.
> > >> The second appears to be a "basic regexp" or grep-style regexp.
> > >>
> > >> This conversion feature in Lisp would be useful to add after the release.
> > >
> > > Very glad to hear that.
> > >
> > > I'm hoping there will also be support for toggling the newline sensitivity
> > > of dot. This means a "doc-matches-newline" mode (aka "single-line" mode)
> > > where `.' will also match newline. Please see the thread "short regexp to
> > > match any character?" from 2006/03/04 and 03/11.
> >
> > I don't know any other matcher where dot matches a newline. Quite
> > more relevant would be inverse character ranges like [^A-Z] that do
> > _not_ match newline by default.
>
> As far as I remember, Perl regexp syntax has a flag to match or not match
> newline by default.
Yes, it. It goes like this:
"This\nLine"
/.*/ "This"
/.*/s Make dot to match (m)ultiline: "This\nLine"
Common modifiers used are:
i Case (i)nsensitive match.
g (g)lobal match; all occurrances until last one
m (m)ultiline achors. The ^ and $ match in between the
lines, not just at the beginning or end of string.
s Change semantics of "." to also match \r or \n.
x e(x)tended. Treat all white space in regexp
non-significant. Makes it possible to wrire readable
regular expressions /Like \s This/
Jari
Re: using non-Emacs regexp syntax, Paul Pogonyshev, 2006/11/29