On 30/10/08 08:56, jice wrote:
>
> Hi,
> I have very long lines made of numbers like this :
> 0324143287911321346876841651023146579841265165769
> I'd like to know if there is a regexp sub expression that can cut this every
> 3 characters in one single command ?
> I know I can easily write a function that could do that but i'm curious to
> know if there is a regexp pattern that would do the trick (something like
> :%s/\%range(0 to 100 step 3)c/ /)
>
> Thanks

It would be easy... except that you'd probably want to do it 
right-to-left, so that the extra single digit or pair of digits be at 
the left end rather than at the right one. Let's see...

What about

        :s/\(\d\{1,3}\)\ze\%(\d\d\d\)\+\%(\D\|$\)/\1,/g

? I didn't try it: if it doesn't work, use u (undo). Or if it _does_ 
work, add % between : and s/ to make it work on the whole file.

The above is supposed to add a comma after every one to three digits (as 
many as possible) when followed by one or more times three digits then a 
nondigit or the end of the line.


Best regards,
Tony.
-- 
hundred-and-one symptoms of being an internet addict:
235. You start naming your kids Fortran, COBOL, Algol, and Pascal.

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

Reply via email to