Hi.
I propose a new function 'matchstrpos()'.
spec:
It returns a list of results of matchstr(), match(), matchend().
:echo matchstrpos("testing!!", "in.")
["ing", 4, 7]
:echo matchstrpos("testing!!", "no")
["", -1, -1]
when 1st arg is list, returns a list of results of matched substring, match(),
index of matched string.
:echo matchstrpos([1, 2, 3, "<<x>>"], '\a')
["x", 3, 2]
example:
"find a pattern, do some procedure to it, and find it again from the end of
matched and repeat these"
now we need call match() (or matchstr() ) and matchend() so do same searching
twice;
let idx = 0
while idx != -1
let res = matchstr(str, pat, idx)
" some procedure to res
let idx = matchend(str, pat, idx)
endwhile
using matchstrpos();
let idx = 0
while idx != -1
let [res, _, idx] = matchstrpos(str, pat, idx)
" some procedure to res
endwhile
patch:
implementation, doc, and test.
https://gist.github.com/ichizok/4601620f1630ad15e720
Thank you.
- Ozaki Kiichi
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.