vim.re
exported names
Methods10
function M.compile(p, defs) -> any
function M.match(s, p, i) -> any
function M.find(s, p, i) -> ...any
function M.gsub(s, p, rep) -> any
function M.updatelocale() -> nil
function M.compile(string: string, defs: nil | table) -> vim.lpeg.Pattern
Compiles the given {string} and returns an equivalent LPeg pattern. The given string may define either an expression or a grammar. The optional {defs} table provides extra Lua values to be used by the pattern.
function M.find(subject: string, pattern: vim.lpeg.Pattern | string, init: nil | integer) -> (nil | integer, nil | integer)
Searches the given {pattern} in the given {subject}. If it finds a match, returns the index where this occurrence starts and the index where it ends. Otherwise, returns nil.
An optional numeric argument {init} makes the search starts at that position in the subject string. As usual in Lua libraries, a negative value counts from the end.
subjectstringpatternvim.lpeg.Pattern | stringinitnil | integer
- nil | integer
: the index where the occurrence starts, nil if no match
- nil | integer
: the index where the occurrence ends, nil if no match
function M.gsub(subject: string, pattern: vim.lpeg.Pattern | string, replacement: string) -> string
Does a global substitution, replacing all occurrences of {pattern} in the given {subject} by {replacement}.
function M.match(subject: string, pattern: vim.lpeg.Pattern | string, init: nil | integer) -> integer | vim.lpeg.Capture | nil
Matches the given {pattern} against the given {subject}, returning all captures.
vim.lpeg.match()
function M.updatelocale()
Updates the pre-defined character classes to the current locale.