On Jan 14, 3:23 pm, ZyX <[email protected]> wrote: > Reply to message «Re: rounding numbers», > sent 10:25:48 14 January 2011, Friday > by rameo: > > > I tried to put another substitute command before str2float but this > > doesn't work.. > > Before printf command doesn't work either. It print the whole text. > > Well, no matter. > > What do you mean when use `before'? With nested function calls like f(g(h(x))) > functions are executed in reversed order: first h, then g, then f. It is > obvious, but I used to make mistakes by putting substitute in a wrong place. > In > either case, you should have put new substitute `before' old substitute (so > that > it will process submatch first), not `before' str2float. > > > \=printf('%.0f',str2float(substitute(substitute(submatch(0),'\.','','g'),',','.',''))) > works for me (though it does not retain a dot). If you want to output with a > dot, either add another substitute after printf, or use other scripting > language > that has better locale support. > > Original message: > > > > > > > > > On Jan 13, 9:13 pm, ZyX <[email protected]> wrote: > > > Reply to message «Re: rounding numbers», > > > sent 21:17:29 13 January 2011, Thursday > > > > by rameo: > > > > That's what I thought also but it will replace all dots in ",", also > > > > the thousand seperators and other dots > > > > No way to re-capture the numbers i.m.o. > > > > No, it won't. First purge dots, and only then replace `,'. > > > I tried to put another substitute command before str2float but this > > doesn't work.. > > Before printf command doesn't work either. It print the whole text. > > Well, no matter. > > > However, thanks for your help. > > > > signature.asc > < 1KViewDownload
Thank you ZyX :) I found a solution to this dot problem. I search with regex only after the dot 15.500,56 select 500,56 and makes it 501 so 15.501 That works very well. Only problem is that it doesn't work with 000 after the dot. p.e. 15.000,56 selects 000,56 and makes it 1 so 15.1 -- 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
