forked from aniani/vim
patch 7.4.1685
Problem: There is no easy way to get all the information about a match. Solution: Add matchstrpos(). (Ozaki Kiichi)
This commit is contained in:
@@ -2020,6 +2020,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}]])
|
||||
@@ -5204,6 +5206,24 @@ matchstr({expr}, {pat}[, {start}[, {count}]]) *matchstr()*
|
||||
:echo matchstr("testing", "ing", 5)
|
||||
< result is "".
|
||||
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()*
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user