On Thu, Feb 28, 2013 at 7:49 AM, Carlo E. Prelz <[email protected]> wrote:
>         Subject: Match array1 with array2
>         Date: gio 28 feb 13 02:48:43 +0900
>
> Quoting Mattias A. ([email protected]):
>
>> I have array1 that contains several web address. Array2 contains the
>> expected endings of array1 values. How can I control that arrays2 values
>> are in array1?
>>
>> array1 = ["https://..../page.html, https://..../page1.html,
>> https://..../page3.html]
>>
>> array2 = ["page.html", "page2.html", "page3.html", "page4.html"]
>
> Use method String#end_with?

... and method Enumerable#all? and probably also URI.parse, URI#path
and File.basename to extract the name of the file from the URI.

There is another more involved approach as well which involves using
method Regexp.union.

Several other solutions are also possible, especially if array2 or
array1 can be large.

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

-- 
[email protected] | 
https://groups.google.com/d/forum/ruby-talk-google?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"ruby-talk-google" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to