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.
newbie (Guest)
on 2006-05-24 00: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
Marcel Molina Jr. (Guest)
on 2006-05-24 00: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
newbie (Guest)
on 2006-05-24 01: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!  :)
Robert K. (Guest)
on 2006-05-24 13:32
(Received via mailing list)
2006/5/23, newbie <removed_email_address@domain.invalid>:
> >> 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
newbie (Guest)
on 2006-05-24 18: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.