How do you wait.match with or ( | )

Posted by Avocado on Tue 26 Nov 2013 03:11 AM — 3 posts, 15,903 views.

#0
local x = wait.match ("*here you see*", 5)

Above line is what I use to match a string, but I would like to try to match more than one string.

What would the line look like?

Let's say if I 'Send ("Look")'
and following two lines show up:

John is here.
Mike is here.
Sam is here.

How do you write
local x = wait.match ("*here you see*", 5)

so that you can write something like:
local x = wait.match ("Sam*" or "Mike*", 5)

in Lua?
Australia Forum Administrator #1
Use a regular expression.

Template:regexp
Regular expressions
  • Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
  • Also see how Lua string matching patterns work, as documented on the Lua string.find page.



 local x = wait.regexp ("^(Sam|Mike)(.*)", 5)
#2
Thank you Nick!
That worked out great!