import { fn } from "https://deno.land/x/ddc_vim@v4.1.0/deps.ts";
const { matchstrpos } = fn;
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.
Can also be used as a method
:
GetText()->matchstrpos('word')