import { fn } from "https://deno.land/x/ddc_vim@v4.0.2/deps.ts";
const { matchend } = fn;
Same as match()
, but return the index of first character
after the match. Example:
:echo matchend("testing", "ing")
results in "7".
Vim doesn't have a strspn() or strcspn() function, but you can do it with matchend():
:let span = matchend(line, '[a-zA-Z]')
:let span = matchend(line, '[^a-zA-Z]')
Except that -1 is returned when there are no matches.
The {start}, if given, has the same meaning as for match()
.
:echo matchend("testing", "ing", 2)
results in "7".
:echo matchend("testing", "ing", 5)
result is "-1".
When {expr} is a List
the result is equal to match()
.
Can also be used as a method
:
GetText()->matchend('word')