Forum: Ruby regular expression question - using 'not' logic with it

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Mmcolli00 M. (Guest)
on 2009-01-08 17:12
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"
  #call method to output results
Jesús Gabriel y Galán (Guest)
on 2009-01-08 17:20
(Received via mailing list)
On Thu, Jan 8, 2009 at 4:11 PM, Mmcolli00 Mom 
>  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

Mmcolli00 M. (Guest)
on 2009-01-08 17:25
This topic is locked and can not be replied to.