break if status =~ /variable/ wildcard possible in Ruby?

Discussion in 'Ruby' started by Mmcolli00 Mom, Aug 5, 2008.

  1. Can you use a wild card with a variable? I have StrgErrFieldName as a
    variable that will hold a number of possible status ids. I want to
    search on what is in the variable. However =~ only works with strings so
    I have tried putting the variable in inside the '/'. Ruby doesn't like
    it. What do you suggest I do? Please help me out. Thanks. Mom mmcolli00

    while true
    status = ie.status()
    break if status =~//+StrgErrFieldName+//
    ie.send_keys("{TAB}")
    end
    --
    Posted via http://www.ruby-forum.com/.
    Mmcolli00 Mom, Aug 5, 2008
    #1
    1. Advertising

  2. Mmcolli00 Mom

    Heesob Park Guest

    Re: break if status =~ /variable/ wildcard possible in Ruby?

    2008/8/5 Mmcolli00 Mom <>:
    > Can you use a wild card with a variable? I have StrgErrFieldName as a
    > variable that will hold a number of possible status ids. I want to
    > search on what is in the variable. However =~ only works with strings so
    > I have tried putting the variable in inside the '/'. Ruby doesn't like
    > it. What do you suggest I do? Please help me out. Thanks. Mom mmcolli00
    >
    > while true
    > status = ie.status()
    > break if status =~//+StrgErrFieldName+//


    Try this:
    break if status =~/#{StrgErrFieldName}/

    > ie.send_keys("{TAB}")
    > end
    >
    >


    Regards,

    Park Heesob
    Heesob Park, Aug 5, 2008
    #2
    1. Advertising

  3. Re: break if status =~ /variable/ wildcard possible in Ruby?

    You are fantastic!
    Thanks
    Mom Mcolli00
    --
    Posted via http://www.ruby-forum.com/.
    Mmcolli00 Mom, Aug 5, 2008
    #3
  4. On 05.08.2008, at 15:54, Mmcolli00 Mom wrote:

    > Can you use a wild card with a variable? I have StrgErrFieldName as a
    > variable that will hold a number of possible status ids. I want to
    > search on what is in the variable. However =3D~ only works with =20
    > strings so
    > I have tried putting the variable in inside the '/'.


    Use #{var}.

    irb> s=3D"abcdef";
    irb> m=3D"b";
    irb> s =3D~ /#{m}/
    =3D> 1


    regards, Sandor Sz=FCcs
    --
    Sandor Szücs, Aug 6, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page