regex question....
Wayne Sierke
ws at au.dyndns.ws
Mon Dec 6 01:15:28 UTC 2010
On Sun, 2010-12-05 at 10:19 -0800, Chip Camden wrote:
> Quoth RW on Sunday, 05 December 2010:
> > On Sat, 4 Dec 2010 20:32:57 -0800
> > Gary Kline <kline at thought.org> wrote:
> >
> > > On Sat, Dec 04, 2010 at 06:49:45PM -0800, xSAPPYx wrote:
> >
> > > > Also, the + operator means '1 or more' but needs escaped:
> > > > %s/[0-9]\+/foo/g
> > >
> > >
> > > Okay. I thought that the + must be perl-only regex... .
> >
> > It's from "Extended" REs rather than perl specifically, it works
> > with sed -E but not plain sed. Not sure about vi.
> For me in works in vim but not in vi.
In vi it requires setting the "extended" option which is unset by
default - "set all" will display "noextended".
In POSIX "extended" REs '+' is a metacharacter so the expression for
"sed -E" and vi with "extended" enabled is simply "[0-9]+" (likewise for
"grep -E" etc).
It seems to be a "gnuism" that an escaped "+" works in "basic" REs, so
it works in grep, gnu sed (gsed) etc.
--
Wayne
More information about the freebsd-questions
mailing list