On 3/05/11 1:29 PM, HaoCheng Zhao wrote:
If I use these command in bash shell:
     echo 'abc' | sed 's/b*/1/g'
It would display:
     1a1c1

But when I try it in VIM:
     (open a document, turn into edit mode and simply type 'abc', and then turn
into command mode)
     :s/b*/1/g
it would display:
     1a1c

I'm wondering why I get different results(no 1 at the tail when using VIM) 
through
the same way (basic regular expression)...
I think /b*/ would match the null string between 'c' and '$', and a substitution
would be taken (just like what 'sed' done above).

I thought you were right, that this was a bug, but I'm not so sure after
reading this comment in the source code:

/*
 * 1. Match empty string does not count, except for first
 * match.  This reproduces the strange vi behaviour.
 * This also catches endless loops.
 */

However, this doesn't explain why when applied to a string like abcde
the null string matches everywhere except at $. It's also very strange
that the pattern /b*\|$/ doesn't match at $, so I still lean towards
this being a bug. I don't have time to look into it more closely,
though.

Ben.



--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to