Andy Wokula wrote:
> ... and I don't mean join().
>
> I'd like to have a function like split(), except for it should collect all
> the _matches_ in a list. "matchlist()" would be a good name for it,
> unfortunately it's already taken.
>
> How would I do it now?
>
" untested
" note: name, if not script-local, must start with an uppercase letter
function Matchlist(string,pattern)
let res = '['
let s = a:string
let p = '\(' . a:pattern . '\).*'
while match(s,a:pattern) != -1
let res .= substitute (s,p,submatch(1)) . ','
let s = substitute(s,a:pattern,'')
endwhile
if res == '['
return []
else
let res = substitute(res,'.$',']')
return eval(res)
endif
endf
Best regards,
Tony.
--
Anthony's Law of Force:
Don't force it; get a larger hammer.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---