Method: Exec::CheckParameter#match_regex
- Defined in:
- lib/exec/check_parameter.rb
#match_regex(str, regexp, msg_if_nok) ⇒ Boolean, String (private)
Check if a string matches a regex
197 198 199 200 201 202 203 204 205 206 |
# File 'lib/exec/check_parameter.rb', line 197 def match_regex(str, regexp, msg_if_nok) msg = "" valid = true regex=Regexp.new(regexp) unless str.match(regex) valid = false msg = msg_if_nok end return valid, msg end |