Regular Expression: Perl and vi

G

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 \<word\> (Question: does \<word\> work for Perl?)

Please add to the list if you know of any difference that I missed.

Thanks.
 
J

John W. Krahn

googler said:
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 \<word\> (Question: does \<word\> 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top