[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

Mmcolli00 Mom

8/5/2008 1:55:00 PM

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

3 Answers

Heesob Park

8/5/2008 2:38:00 PM

0

2008/8/5 Mmcolli00 Mom <mmc_collins@yahoo.com>:
> 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

Mmcolli00 Mom

8/5/2008 3:42:00 PM

0

You are fantastic!
Thanks
Mom Mcolli00
--
Posted via http://www.ruby-....

Sandor Szücs

8/6/2008 9:48:00 AM

0

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