开发者

regex in vimscript

let test = 'a href="http://www.google.com">www.google.com</a;'

In vimscript, how can I get http://www.google.com out of this using a regexp, and store it in another variable?

开发者_高级运维

I can't seem to find any documentation about this.


let url = matchstr(test, '\ca href=\([''"]\)\zs.\{-}\ze\1')
if empty(url) 
   throw "no url recognized into ``".test."''"
endif

For more information, see:

:h matchstr()
:h /\c
:h /\zs
:h /\{-
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜