2010-06-28 42 views
12
let test = 'a href="http://www.google.com">www.google.com</a;' 

Vimscript中,我怎麼能得到http://www.google.com擺脫這種使用正則表達式,並將其存儲在另一個變量?正則表達式Vimscript中

我似乎無法找到關於此的任何文檔。

回答

24
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 /\{- 
+0

謝謝!會看起來那些。我只是不知道在哪裏尋找vimscript – guest 2010-06-28 19:23:40

+3

@guest:最糟糕的情況是,您可以瀏覽':help functions'(按字母順序排列)或':help function-list'(按類別)查找函數。 – Cascabel 2010-06-28 19:27:39