[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

regular expression question - using 'not' logic with it

Mmcolli00 Mom

1/8/2009 3:12:00 PM

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
--
Posted via http://www.ruby-....

2 Answers

Jesús Gabriel y Galán

1/8/2009 3:20:00 PM

0

On Thu, Jan 8, 2009 at 4:11 PM, Mmcolli00 Mom <mmc_collins@yahoo.com> wrote:
> 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

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.

Mmcolli00 Mom

1/8/2009 3:25:00 PM

0

Thanks!
--
Posted via http://www.ruby-....