diff options
author | Michael Ennen <mike.ennen@gmail.com> | 2016-11-24 23:13:30 -0700 |
---|---|---|
committer | Michael Ennen <mike.ennen@gmail.com> | 2016-12-06 15:52:48 -0700 |
commit | 6fea2dfd26cb902d7b2f52f53ccca9befef2b442 (patch) | |
tree | a12933cbd0a18015e69221df92e7d9294ceaeb44 /runtime | |
parent | 61150294967f2522cb1774e29e49a3386d3bcee5 (diff) | |
download | rneovim-6fea2dfd26cb902d7b2f52f53ccca9befef2b442.tar.gz rneovim-6fea2dfd26cb902d7b2f52f53ccca9befef2b442.tar.bz2 rneovim-6fea2dfd26cb902d7b2f52f53ccca9befef2b442.zip |
vim-patch:7.4.1685
Problem: There is no easy way to get all the information about a match.
Solution: Add matchstrpos(). (Ozaki Kiichi)
https://github.com/vim/vim/commit/7fed5c18f8577b75404b80d8b9a9907b1bbd27e4
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/eval.txt | 20 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index cca53db531..53f14c7d47 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2032,6 +2032,8 @@ matchlist({expr}, {pat}[, {start}[, {count}]]) List match and submatches of {pat} in {expr} matchstr({expr}, {pat}[, {start}[, {count}]]) String {count}'th match of {pat} in {expr} +matchstrpos( {expr}, {pat}[, {start}[, {count}]]) + List {count}'th match of {pat} in {expr} max({list}) Number maximum value of items in {list} min({list}) Number minimum value of items in {list} mkdir({name} [, {path} [, {prot}]]) @@ -5019,6 +5021,24 @@ matchstr({expr}, {pat}[, {start}[, {count}]]) *matchstr()* When {expr} is a |List| then the matching item is returned. The type isn't changed, it's not necessarily a String. +matchstrpos({expr}, {pat}[, {start}[, {count}]]) *matchstrpos()* + Same as |matchstr()|, but return the matched string, the start + position and the end position of the match. Example: > + :echo matchstrpos("testing", "ing") +< results in ["ing", 4, 7]. + When there is no match ["", -1, -1] is returned. + The {start}, if given, has the same meaning as for |match()|. > + :echo matchstrpos("testing", "ing", 2) +< results in ["ing", 4, 7]. > + :echo matchstrpos("testing", "ing", 5) +< result is ["", -1, -1]. + When {expr} is a |List| then the matching item, the index + of first item where {pat} matches, the start position and the + end position of the match are returned. > + :echo matchstrpos([1, '__x'], '\a') +< result is ["x", 1, 2, 3]. + The type isn't changed, it's not necessarily a String. + *max()* max({list}) Return the maximum value of all items in {list}. If {list} is not a list or one of the items in {list} cannot diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 4d3ad49f1f..2896611274 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -592,6 +592,7 @@ String manipulation: *string-functions* match() position where a pattern matches in a string matchend() position where a pattern match ends in a string matchstr() match of a pattern in a string + matchstrpos() match and postions of a pattern in a string matchlist() like matchstr() and also return submatches stridx() first index of a short string in a long string strridx() last index of a short string in a long string |