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

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

2008/8/5 Mmcolli00 Mom [email protected]:

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 H.

You are fantastic!
Thanks
Mom Mcolli00

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 =~ only works with
strings so
I have tried putting the variable in inside the ‘/’.

Use #{var}.

irb> s=“abcdef”;
irb> m=“b”;
irb> s =~ /#{m}/
=> 1

regards, Sandor
Szücs

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs