Help in writing vim script

30 views
Skip to first unread message

Siddhant Gupta

unread,
Jun 15, 2016, 3:03:20 AM6/15/16
to vim_use
I have a variable containing Result: "/tmp/abcd/1234", I want to extract /tmp/abcd/1234 in another variable.How can I do this?

John Little

unread,
Jun 15, 2016, 10:51:21 PM6/15/16
to vim_use
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

Reply all
Reply to author
Forward
0 new messages