Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > break if status =~ /variable/ wildcard possible in Ruby?

Reply
Thread Tools

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

 
 
Mmcolli00 Mom
Guest
Posts: n/a
 
      08-05-2008
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/.

 
Reply With Quote
 
 
 
 
Heesob Park
Guest
Posts: n/a
 
      08-05-2008
2008/8/5 Mmcolli00 Mom <(E-Mail Removed)>:
> 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

 
Reply With Quote
 
 
 
 
Mmcolli00 Mom
Guest
Posts: n/a
 
      08-05-2008
You are fantastic!
Thanks
Mom Mcolli00
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Sandor Szcs
Guest
Posts: n/a
 
      08-06-2008
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
--




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wildcard String Comparisons: Set Pattern to a Wildcard Source chaoticcranium@gmail.com Python 7 10-05-2010 09:26 PM
`if (!p ? i++ : 0) break;' == `if (!p){ i++; break;}' ? lovecreatesbea...@gmail.com C Programming 12 04-14-2008 07:59 AM
Recommend a free 'Status Monitor' or 'Dashboard' to report overnight tasks status? Shug Java 13 12-15-2006 06:22 PM
Recommend a free 'Status Monitor' or 'Dashboard' to report overnight tasks status? Shug C++ 13 12-15-2006 06:22 PM
POST problem - IIS sc-win32-status:64; sc-status:400 saha ASP .Net 0 07-14-2005 07:10 AM



Advertisments