Forum: Ruby do i need a regex?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F06f8fad11810690c6e743c0fffc4017?d=identicon&s=25 newbie (Guest)
on 2006-05-23 22:19
i am trying to match the string "--(null)--" in ruby

i am doing this after reading a line

if line.match("--null--")
#code here

its not working though

would i need a regex
Cee0292fffa691f1fb320d5400200e99?d=identicon&s=25 Marcel Molina Jr. (Guest)
on 2006-05-23 22:24
(Received via mailing list)
On Wed, May 24, 2006 at 05:19:53AM +0900, newbie wrote:
> i am trying to match the string "--(null)--" in ruby
>
> i am doing this after reading a line
>
> if line.match("--null--")
> #code here
>
> its not working though
>
> would i need a regex

You *could* use a regex but you don't *need* to if all you care about is
inclusion of that string.

  if line.include?('--null--')

marcel
F06f8fad11810690c6e743c0fffc4017?d=identicon&s=25 newbie (Guest)
on 2006-05-23 23:13
>> would i need a regex
>
> You *could* use a regex but you don't *need* to if all you care about is
> inclusion of that string.
>
>   if line.include?('--null--')
>
> marcel

marcel that worked perfectly

thank you very much!  :)
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (Guest)
on 2006-05-24 11:32
(Received via mailing list)
2006/5/23, newbie <a@a.org>:
> >> would i need a regex
> >
> > You *could* use a regex but you don't *need* to if all you care about is
> > inclusion of that string.
> >
> >   if line.include?('--null--')
> >
> > marcel
>
> marcel that worked perfectly

I'm surprised: in your original posting you mentioned the string
"--(null)--" which is somewhat different from "--null--"...

robert
F06f8fad11810690c6e743c0fffc4017?d=identicon&s=25 newbie (Guest)
on 2006-05-24 16:57
>> marcel that worked perfectly
>
> I'm surprised: in your original posting you mentioned the string
> "--(null)--" which is somewhat different from "--null--"...
>
> robert

i typed mine in with the parentheses
This topic is locked and can not be replied to.