ah, ruby is so convenient compared to other languages:). This I guess is a legacy from my days of C programming where you had to declare everything up front to allocate space etc. I'll fix this in Rubyforge asap. tyvm :) rgds Steve --- "David A. Black" <dblack / wobblini.net> wrote: > Hi -- > > On Wed, 18 May 2005, Steve Callaway wrote: > > > Yeah, straightforward enough, moreover you can > process > > an array of vars as in the snippet I put up on > > Rubyforge: > > > > # function to regexp vars > > def is_element_in_string?(in_string, in_array) > > in_array.each do |line| > > rx_test = /#{line}/ > > if in_string =~ rx_test > > return true > > end > > end > > return false > > end > > Let Ruby do the work for you :-) > > def is_element_in_string?(str, elements) > elements.any? {|e| /#{e}/.match(str) } > end > > > # as an example we may wish to see whether a list > of > > football match results > > # contains a result of a team we are interested in > > varray = Array.new > > # now populate the array with reegxps you wish to > > match... > > varray = ["Plymouth Argyle", "Blackburn Rovers" , > > "Manchester .*", "Tott.*"] > > You're not populating the array; you're discarding > the array and > creating a completely new one :-) The array you > created previously > ceases to exist. > > You can either just leave out that first assignment, > or if you have > some reason to create and populate the array in two > steps, you could > do: > > varray = Array.new > varray.replace(["Plymouth ...", "...", ...]) > > but I can't think of any reason to do that. I would > just assign the > array to the variable, as in your second assignment. > > > David > > -- > David A. Black > dblack / wobblini.net > > Discover Yahoo! Find restaurants, movies, travel and more fun for the weekend. Check it out! http://discover.yahoo.com/weekend.html