iterating throught 2 arraylists

cengineer

Member
Joined
Aug 17, 2009
Messages
8
Programming Experience
Beginner
I have two arraylists that contains links in one and the root url in the other. Sometimes the lists dont equal in number and I would like to iterate through the links list and if it contains a matching root url add it to a third list but also avoid any duplicates. I tried this but am not getting consistent results.

Any ideas appreciated, thanks.
VB.NET:
           For Each link As String In urls
                For Each part As String In post
                    If part.Contains(link) Then
                        newPost.Add(part)
                    End If
                Next
           Next

Perhaps there is another way; basically the part in post is a link to a page and contains the root url( which is link in urls). After extracting all these I need to ensure the 2 lists match.

Let me add some more info for clarification. Arraylist post contains the first few items as an example:
0 - blogdetecnologia.com/actualidad/…
1- blogdetecnologia.com
2- landmine.com.ph/para-las-ventas-del-iphone-apple-…
3- landmine.com.ph
and urls contains
0 - blogdetecnologia.com
1 - landmine.com.ph
this is what the problem is; i get new list with the same post items after iterating through it
 
Try....

VB.NET:
 For Each link As String In urls
                For Each part As String In post
                    If part.Contains(link) AndAlso Not newPost.Contains(part) Then
                        newPost.Add(part)
                    End If
                Next
           Next
 
Thanks for the response. It did not work in this case. Let me try and reiterate with a new example;

the arraylist1 contains the following items:

1 -http://www.vbdotnetforums.com/newreply.php?do=newreply&noquote=1&p=112986

2 -http://www.vbdotnetforums.com/newreply.php?/helloworld/html

3 -http://www.vbdotnetforums.com/newreply.php?/helloworld

4 -http://www.vbdotnetforums.com/newreply.php

and I need the urls 2,3,4 removed from that arraylist1. I have url 4 in arraylist 2 occurring once. I can compare the two list but I cannot remove the urls 2, 3, 4 without removing url 1 from arraylist 1.
 
Back
Top