Regular Expression: Perl and vi
Regular Expression: Perl and vi
am 13.08.2007 19:58:49 von googler
I am trying to create a list of the differences in regular expression
for Perl and vi. I have been using both Perl and vi, and get confused
by this sometimes. There are a few that I already know of.
1. In Perl, characters like (, { etc when used as metacharacter can be
used by themselves (without using a \). In vi, they should be escaped
with a \. (Question: what is the full list of the metacharacters where
we see this difference?)
2. In Perl, non-greedy search can be done by using a ? character
(like .*?). In vi, this is done as .\{-}
3. In Perl, zero or one match can be achieved by putting a ? character
after the pattern. In vi, this is done by \=
4. In Perl, the RE for matching only a particular word is \bword\b .
In vi, it is \ (Question: does \ work for Perl?)
Please add to the list if you know of any difference that I missed.
Thanks.
Re: Regular Expression: Perl and vi
am 13.08.2007 21:35:55 von Dummy
googler wrote:
> I am trying to create a list of the differences in regular expression
> for Perl and vi. I have been using both Perl and vi, and get confused
> by this sometimes. There are a few that I already know of.
>
> 1. In Perl, characters like (, { etc when used as metacharacter can be
> used by themselves (without using a \). In vi, they should be escaped
> with a \. (Question: what is the full list of the metacharacters where
> we see this difference?)
>
> 2. In Perl, non-greedy search can be done by using a ? character
> (like .*?). In vi, this is done as .\{-}
>
> 3. In Perl, zero or one match can be achieved by putting a ? character
> after the pattern. In vi, this is done by \=
>
> 4. In Perl, the RE for matching only a particular word is \bword\b .
> In vi, it is \ (Question: does \ work for Perl?)
>
> Please add to the list if you know of any difference that I missed.
Get the book:
http://www.oreilly.com/catalog/regex3/index.html
It should explain most if not all of the differences.
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
Re: Regular Expression: Perl and vi
am 15.08.2007 15:58:22 von Brian Blackmore
John W. Krahn wrote:
> googler wrote:
> > I am trying to create a list of the differences in regular expression
> > for Perl and vi. I have been using both Perl and vi, and get confused
> > by this sometimes. There are a few that I already know of.
> >
> > 1. In Perl, characters like (, { etc when used as metacharacter can be
> > used by themselves (without using a \). In vi, they should be escaped
> > with a \. (Question: what is the full list of the metacharacters where
> > we see this difference?)
> >
> > 2. In Perl, non-greedy search can be done by using a ? character
> > (like .*?). In vi, this is done as .\{-}
> >
> > 3. In Perl, zero or one match can be achieved by putting a ? character
> > after the pattern. In vi, this is done by \=
> >
> > 4. In Perl, the RE for matching only a particular word is \bword\b .
> > In vi, it is \ (Question: does \ work for Perl?)
> >
> > Please add to the list if you know of any difference that I missed.
> Get the book:
> http://www.oreilly.com/catalog/regex3/index.html
> It should explain most if not all of the differences.
:help perl-patterns
--
Brian Blackmore
blb8 at po dot cwru dot edu
Re: Regular Expression: Perl and vi
am 15.08.2007 18:37:15 von jgamble
In article ,
Brian Blackmore wrote:
>John W. Krahn wrote:
>> googler wrote:
>> > I am trying to create a list of the differences in regular expression
>> > for Perl and vi. I have been using both Perl and vi, and get confused
>> > by this sometimes. There are a few that I already know of.
>> >
>> > 1. In Perl, characters like (, { etc when used as metacharacter can be
>> > used by themselves (without using a \). In vi, they should be escaped
>> > with a \. (Question: what is the full list of the metacharacters where
>> > we see this difference?)
>> >
>> > 2. In Perl, non-greedy search can be done by using a ? character
>> > (like .*?). In vi, this is done as .\{-}
>> >
>> > 3. In Perl, zero or one match can be achieved by putting a ? character
>> > after the pattern. In vi, this is done by \=
>> >
>> > 4. In Perl, the RE for matching only a particular word is \bword\b .
>> > In vi, it is \ (Question: does \ work for Perl?)
>> >
>> > Please add to the list if you know of any difference that I missed.
>
>> Get the book:
>
>> http://www.oreilly.com/catalog/regex3/index.html
>
>> It should explain most if not all of the differences.
>
>:help perl-patterns
>
Which does work in vim, but the OP may not be using that version of vi.
--
-john
February 28 1997: Last day libraries could order catalogue cards
from the Library of Congress.