Jocelyn delalande
Jocelyn delalande

Reputation: 5384

Pattern matching & capture a list of words in lua

Using lua pattern-matching, I would like to match and capture "/egg/" or "/spam/" words

Expected string.find(haystack, pattern) results:

"/spam/"    -> captures "spam"
"/egg/"     -> captures "egg"
"/spamegg/" -> returns nil and captures nothing
"/foo/"     -> returns nil and captures nothing

I know how to match either "egg" or "spam" but could not find a way to expresse the logical OR (though it seems vory simple).

Upvotes: 1

Views: 917

Answers (1)

lhf
lhf

Reputation: 72312

Lua patterns do not support OR.

Upvotes: 2

Related Questions