Class Match

Used for searching and replacing text.

A match generator is returned from Editor:match which can be used to iterate search results. While looping through matches, if the document is modified by any method other than the match object's replace method, this may cause the match generator to lose its place. Also, do not attempt to store the match object for later access outside the loop; it will not be usable.

See also:

Usage:

    for m in editor:match("teh") do
        m:replace("the")
    end
    

Fields

Match.pos Beginning position of the located match.
Match.len Length of text matched.
Match.text The actual text matched.

Methods

Match:replace(text) Replaces the matched text.

Metamethods

Match:__tostring() String representation of the match.


Fields

Match.pos
Beginning position of the located match.
  • pos int (readonly)
Match.len
Length of text matched.
  • len int (readonly)
Match.text
The actual text matched.
  • text string (readonly)

Methods

Match:replace(text)
Replaces the matched text.

Parameters:

  • text string replacement text

Metamethods

Match:__tostring()
String representation of the match.
generated by LDoc 1.4.6