I was trying to figure out a way to compare two strings and returns their 'common' words, given that the strings are always in lowercase, I wanted to create a function for this..for example
str1 = "this is a test"
str2 = "saldkasl test asdasd"
result = stringcompare(str1, str2) 'returns "test"
the common word between the two strings should be "test" and if, the two strings have two or more common words, the function should concatenate the strings
str1 = "this is another test"
str2 = "another asdsada test asdsa"
result = stringcompare(str1, str2) ' returns "another test"
i have found a useful link, it gave me an idea but somehow something is really lacking
A pseudocode of what I'm doing right now is this,
**
'1st: separate the words by every space, " ", then store it in an array or list
'2nd: compare each item on the list, if equal then store to variable 'result'
**
is this okay? I think it is slow and maybe there is someone out there that has a better approach on this..thanks