Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the alternation operator in Lua patterns?

In regex, | is used for alternation. What is the corresponding character in Lua patterns?

like image 310
Jason Avatar asked Feb 02 '23 05:02

Jason


1 Answers

First, note that Lua patterns are not regular expressions; they are their own simpler matching language (with different benefits and drawbacks).

Per the specification I've linked to above, and per this answer, there is no alternation operator in a Lua pattern. To get this functionality you'll need to use a more powerful Lua construct (like LPEG or a Lua Regex Library).

like image 119
Phrogz Avatar answered Mar 16 '23 00:03

Phrogz