Andrew
Andrew

Reputation: 33

Lua pattern matching for empty string

after trying and reading Lua's doc on patterns, I couldn't figure it out.

I am using an OBS plugin to activate a source on text document change, and the plugin uses Lua pattern matching. I would like to trigger the source whenver the document is EMPTY and only empty. How can I go about doing this?

Example, using the non-empty pattern match:

enter image description here

Thank you for any help!

Upvotes: 2

Views: 753

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626738

Pattern matching an empty string is

^$

where

  • ^ - matches the start of string position
  • $ - matches the end of string position.

That is, start and end of string positions must be the same position in the string.

Upvotes: 1

Related Questions