Re: How to avoid this greedy match?
- From: krahnj@xxxxxxxxx (John W. Krahn)
- Date: Tue, 29 Jan 2008 01:06:35 -0800
yitzle wrote:
I'm not sure how it works, but I think <> or \<\> is a RegEx reserved
character for word matching.
That only works for other regular expression engines in programs like vi/less/grep etc.
$ echo "abcdefg cde lmncdeopq" | grep -o -e 'cde'
cde
cde
cde
$ echo "abcdefg cde lmncdeopq" | grep -o -e '\<cde\>'
cde
I seem to remember that Jeffrey Friedl's[1] book describes a way to emulate left and right word boundaries in Perl's regular expressions.
[1] http://www.oreilly.com/catalog/regex3/index.html
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
.
- Follow-Ups:
- Re: How to avoid this greedy match?
- From: Dr.Ruud
- Re: How to avoid this greedy match?
- From: Uri Guttman
- Re: How to avoid this greedy match?
- References:
- Re: How to avoid this greedy match?
- From: News Howardz
- RE: How to avoid this greedy match?
- From: Ajay Nagrale
- Re: How to avoid this greedy match?
- From: Yitzle
- Re: How to avoid this greedy match?
- Prev by Date: Re: print records that match regexp
- Next by Date: Re: file.db VS filedb
- Previous by thread: RE: How to avoid this greedy match?
- Next by thread: Re: How to avoid this greedy match?
- Index(es):
Relevant Pages
|