Skip to content

Instantly share code, notes, and snippets.

@thinca
Created April 17, 2014 03:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save thinca/10951074 to your computer and use it in GitHub Desktop.
function! s:scan(str, pattern)
let pos = 0
let results = []
while 1
let start = match(a:str, a:pattern, pos)
if start < 0
break
endif
let end = matchend(a:str, a:pattern, pos)
if start != end
let results += [a:str[start : end - 1]]
let pos = end
else
let pos = end + 1
endif
endwhile
return results
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment