mercredi 8 mai 2019

Lua - Nested if statements

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)

end
end
end

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.

Aucun commentaire:

Enregistrer un commentaire