Ответ 1
let url = matchstr(test, '\ca href=\([''"]\)\zs.\{-}\ze\1')
if empty(url)
throw "no url recognized into ``".test."''"
endif
Для получения дополнительной информации см.
:h matchstr()
:h /\c
:h /\zs
:h /\{-
let test = 'a href="#" onclick="location.href='http://www.google.com'; return false;">www.google.com</a;'
В vimscript, как я могу получить http://www.google.com
из этого с помощью regexp и сохранить его в другой переменной?
Я не могу найти документацию об этом.
let url = matchstr(test, '\ca href=\([''"]\)\zs.\{-}\ze\1')
if empty(url)
throw "no url recognized into ``".test."''"
endif
Для получения дополнительной информации см.
:h matchstr()
:h /\c
:h /\zs
:h /\{-