开发者

regex in vimscript

开发者 https://www.devze.com 2023-01-05 12:10 出处:网络
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?开发者_高级运维
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

精彩评论

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