On Thu, 28 Jul 2011, niva wrote:

Hi,

Using net view command on windows provide me the following output:

\\255.255.255.255\d$\DIR some text

I would like to substitute this network path \\255.255.255.255\d$\DIR to the output.


I have done this assuming path is \\255......\DIR

let pattern=substitute(path,'\\','\\\\','g')
let pattern=substitute(pattern,'\$','\\$','')
let pattern=substitute(pattern,'\.','\\.','')

this works fine and obtain this \\\\255\.255\.255\.255\\d\$\\DIR when I echo pattern var.

Now I launch substitute(output,pattern,'','g') andit fails, my output is still
\\255.255.255.255\d$\DIR some text

The substitute() function doesn't modify its first argument, it returns the result. If you want the 'output' variable to contain the result you need to set it to the result, the way you're doing above:

let output=substitute(output,pattern,'','g')

If that's not the problem, you need to provide some more complete code. E.g.:

==> test.vim <==
" how I interpreted what you wrote:

" after the 'path' and 'pattern' stuff you end up with:
let pattern='\\\\255\.255\.255\.255\\d\$\\DIR'
echo 'pattern is:' pattern

let output='\\255.255.255.255\d$\DIR some text'
echo 'output is:' output
echo 'result of substitute is:' substitute(output, pattern, '', 'g')
echo 'after substitute, output is unchanged:' output

" this is the part I described above:
let output=substitute(output, pattern, '', 'g')
echo 'after let, output is:' output
================

--
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