I wrote my first regex and an if condition to check a passed def argument loop.
It doesn't seem to be working properly, and I am guessing I have something wrong with the regex. The condition runs, but it says the value doesn't match the regex when it does match the pattern I want, and vice-versa.
The pattern I need is like this: 123456_12345_ABC_123:
6 digits
underscore
5 digits (may include 0 padding)
underscore
3 upper case letters
underscore
3 digits (may include 0 padding)
Here is my code:
if ev_val.match(/[0-9]{6}(_)[0-9]{5}(_)[a-z]{3}(_)[0-9]{3}/)
puts "#{ev_val} matches required batch naming convention"
else
puts "#{ev_val} doesn't match required batch naming convention\nSTOPPING SCRIPT!!!"
exit
end
If anyone has any thoughts, I would greatly appreciate it!