Wednesday, June 15, 2016

Re: Help in writing vim script

On Wednesday, June 15, 2016 at 7:03:20 PM UTC+12, Siddhant Gupta wrote:
> I have a variable containing Result: "/tmp/abcd/1234", I want to extract /tmp/abcd/1234 in another variable.How can I do this?

That depends on what you want to match around what you want. Matching the word Result and the colon and quotes, and assuming there's nothing else,

let x = 'Result: "/tmp/abcd/1234"'
let y = substitute(x, 'Result: "\(.*\)"', '\1', '')

is one way to do it. Add .* to the beginning or end or both if there's characters to ignore there.

Regards, John Little

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment