[Note: parts of this message were removed to make it a legal post.]
I'm not sure what you're going to gain from a regex if it's a specific
string and not a pattern.
irb(main):001:0> a = "Hello World"
=> "Hello World"
irb(main):002:0> !(a.include? 'Hello')
=> false
irb(main):003:0>
It seems you'd want to wrap that into a method to make the intent a little
more obvious
irb(main):011:0> def should_filter?(source, word)
irb(main):012:1> source.include? word
irb(main):013:1> end
=> nil
irb(main):014:0> should_filter?(a, 'Hello')
Just a thought.
to make the regex work as in your example though, you'd do this:
irb(main):021:0> !(a =~ /hello/i)
=> false
(case insensitive matching)
On Tue, Apr 15, 2008 at 8:59 AM, Dipesh Batheja <>
wrote:
> Can somebody hep me with a very simple regular expression. I want to
> write an regex which if matches a specific string should return false.
> for example:
> if i have string "Hello world", and i want to say, if you find "hello"
> in this string then return false. Can someone explain how to write this?
> --
> Posted via http://www.ruby-forum.com/.
>
>
--
Jeff Schoolcraft
http://thequeue.net/blog/
Microsoft MVP