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

M

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+//
ie.send_keys("{TAB}")
end
 
H

Heesob Park

2008/8/5 Mmcolli00 Mom said:
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
 
S

Sandor Szücs

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top