Regular expression question - using 'not' logic with it

I know this is probably so easy, but I just can’t find any documentation
on it because it is not character class value.

If 4 specific values exists, I do not want to output anything. How can I
check that these values do not exist, otherwise output?

if overrideVal1 != /Stamp/ or overrideVal2 != /Create/ or overrideVal3
!= /6400/ or overrideVal4 != /5400000/ then
puts “No results”
else
#call method to output results
getValues()
end

On Thu, Jan 8, 2009 at 4:11 PM, Mmcolli00 Mom [email protected]
wrote:

else
#call method to output results
getValues()
end

It’s not clear to me how many strings you have to check, but if you
want to see if
a string doesn’t match four possibilities in a regular expression this
is one way:

irb(main):001:0> a = “abcde”
=> “abcde”
irb(main):004:0> a !~ /Stamp|Create|6400|5400000/
=> true
irb(main):005:0> a = “TimeStamp”
=> “TimeStamp”
irb(main):006:0> a !~ /Stamp|Create|6400|5400000/
=> false

Jesus.

Thanks!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs