Skip to main content
Module

x/denops_std/function/vim/mod.ts>assert_match

📚 Standard module for denops.vim
Go to Latest
function assert_match
import { assert_match } from "https://deno.land/x/denops_std@v6.4.0/function/vim/mod.ts";

When {pattern} does not match {actual} an error message is added to v:errors. Also see assert-return. The error is in the form "Pattern {pattern} does not match {actual}". When {msg} is present it is prefixed to that.

{pattern} is used as with =~: The matching is always done like 'magic' was set and 'cpoptions' is empty, no matter what the actual value of 'magic' or 'cpoptions' is.

{actual} is used as a string, automatic conversion applies. Use "^" and "$" to match with the start and end of the text. Use both to match the whole text.

Example:

assert_match('^f.*o$', 'foobar')

Will result in a string to be added to v:errors: test.vim line 12: Pattern '^f.*o$' does not match 'foobar'

Can also be used as a method:

getFile()->assert_match('foo.*')

Parameters

denops: Denops
pattern: unknown
actual: unknown
optional
msg: unknown

Returns

Promise<number>