View Single Post
  #1 (permalink)  
Old 12-02-2008, 03:41 AM
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 249
Matching phrases

I can't figure this out. I spent a lot of time (weeks!) trying to figure it out but no success.

What I want is for common_phrase to have the phrases in common from both mySplitString and mySplitString2separated by ,,.
Code:
	var common_phrase = "";//the last result of the string
	k=0;
	var count=0;
	for(var i=0; i < wordCollection.length; i++){ //length of the collection of words in common in the two strings mySplitString and mySplitString2
		for(var j=0; j < mySplitString.length; j++){ //picks a word and runs through 2nd array
			if(wordCollection[i] == mySplitString[j]){ //when match found
				for(k=0; k < mySplitString2.length; k++){
					if(wordCollection[i] == mySplitString2[k]){
						for(m=0; m<wordCollection.length; m++){
							if(mySplitString[j+m] == mySplitString2[k+m]){
								common_phrase += mySplitString[j+m]+" "; //records word
								count++;
							}
						}
					}else{
						if(count > 0){
							common_phrase += ",,";
							count=0;
						}
					}
				}	
			}
		}
	}
__________________
Gilgal's website:
Wheel Of God
Now easy to post scripture verses!
Portfolio