views:

65

answers:

2
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.

thanks in advance!

+2  A: 
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 /\{-
Luc Hermitte
thanks! will look those up. i just don't know where to search for when it comes to vimscript
guest
@guest: Worst case, you can skim through `:help functions` (alphabetical) or `:help function-list` (by category) to find functions.
Jefromi
A: 

i just don't know where to search for when it comes to vimscript

very good article series by damian conway here about vim scripting: http://www.ibm.com/developerworks/linux/library/l-vim-script-1/index.html

thegeek