Ozaki Kiichi wrote:
> 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
Thanks, I'll put it in the todo list
--
Why is "abbreviation" such a long word?
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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.