List Info

Thread: selecting an item from a list using a regular expression




selecting an item from a list using a regular expression
country flaguser name
United States
2007-04-13 11:36:45
I have items I'm trying to pick from a select list of this
form:

  <groupID> - <text string>

For example, the list might be:

  4 - Denver
  5 - Atlanta
  1950 - New York City

The items in the list are always changing, and I want to
pick an item by 
just the number.  So, this actually works to select the last
item in the 
list above:

  ie.select_list( :name ,
"groupID").select(/1950 - /)

However, I have the number (the groupDI) in a variable.  So
the question is:

How does one get the value of a variable into a regular
expression?

Paul Hammer

____________________________________________________________
_____
Download Messenger. Join the i’m Initiative. Help make a
difference today. 
http://im.live.com/messenger/im/home/?source=TAGHM_APR07



_______________________________________________
Wtr-general mailing list
Wtr-generalrubyforge.org
htt
p://rubyforge.org/mailman/listinfo/wtr-general
Re: selecting an item from a list using a regular expression
user name
2007-04-13 11:50:21
> How does one get the value of a variable into a regular
expression?

require 'test/unit'

class TC_Spike < Test::Unit::TestCase
  def test_1950

var = 1950
data = "xxx1950xxx"

assert_match(/#/,data)
end
end
_______________________________________________
Wtr-general mailing list
Wtr-generalrubyforge.org
htt
p://rubyforge.org/mailman/listinfo/wtr-general

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )