Quantcast
Channel: Lua - Nested if statements - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Lua - Nested if statements

$
0
0

I'm looking to check the validity of multiple filenames within a folder using LUA.

I can get the filenames passed through as variables (defined as a.message) and I need the script to run through all the regex patterns, and if it does not match any of them, then print "We need an alarm".

a = alarm.get ("GF91908920-49330")   if regexp (a.message,"/CCF_[0-9]{6}_[0-9]{2}.csv/") then      if regexp (a.message,"/Issues_[0-9]{4}-[0-9]{2}-[0-9]{2}.csv/") then        if regexp (a.message,"/POL_Operator_[0-9]{6}_[0-9]{2}.csv/") then         else print ("We need an alarm - ", a.message)endendend

So, if variable matches one of the regex patterns, great, then end. If not, move on and check for a match against any of the other patterns, again, ending if a match is found.

If no matches are found amongst any of the regex then print "We need an alarm".

I hope that's clear enough.

Thanks.


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>