LegolasKiss wrote:
[...]
> 
> so the log is like this now:
> 
> time cost is 3.  1234
> time cost is 3.   234
> time cost is 3.     5
> .....
> 
> i want to use the regular expression in vim to change all spaces into
> ``0'',but i can't do this in one operation.
> 
> my way is like this:
> <esc>:%s/\(\d\.\ *\)\ /\10/g
> 
[...]

This doesn't work, because it matches only in 1 position ( the
first digit ), no matter how many whitespaces are following the dot.

1st try using '\zs' :

:s/\d\.\s*\zs\s/0/g

Still doesn't work, presumably because '\zs' is applied after
the pattern matched and so the `real` start is still at the '\d'.

2nd try :

:s/\s/0/g

This matches any single whitespace, looks like it has some
potential. Let's make it look behind for the digit part.
The '\v' avoids leaning toothstick sick.

:s/\v(\d\.\s*)@<=\s/0/g

This does work. It matches a whitespace and afterwards checks
whether the match is in a correct position.
Finally check if there really is a digit following, making it
more robust.

:s/\v(\d\.\s*)@<=\s\ze\s*\d/0/g

-ap



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui