How to compare two strings and score the output

datatypes
code

#1

Hi

I need to compare two strings like skills=“java,c++,c#” with skillset=“java,j2ee”. In both the string java is common so it should produce output as in interger value 1… Already I tried to split the string in List but the syntaz is not working for me…If anyone knows help me out


#2

string1="java,c++,c#"
string2=“java,j2ee”

listMatch= Split(string2,",").Intersect(Split(string1,",")).ToList()

perform your logic after this (foreach based on count)


Matching a string based on similarity i.e. not exact match
#3

yup tq vvaidya but if i have stings as string1=“marketing,sales” and string2=“marketing management,sale management” and I converted those stings in List passed loops but it generates count=0, i need count=2… and anyone know how to sort list


#4
  1. marketing is not an individual value in string2
  2. string1 has sales and string2 has sale
  3. you can replace space by comma and use contains in if condition.

Hope it helps.


#5

I tried contains… still it is not working…


#6

This may help:

http://www.dotnetcurry.com/csharp/189/csharp-string-substring-split-functions


#7

@badita Can you make the external urls open in a new tab (I’m using chrome).


#8

@vvaidya you can set those in your user profile to always open in new tab


#9

Thanks @andrzej.kniola. Didn’t know that, will check out.


#10

im attaching my file… please look into it and give me suggestions to get approximate score countcompare.xaml (28.6 KB)


#11

hi vvaidya

using intersect how can i trim strings within string1 and change the cases… because of the whitespace and case strings are not getting matched… can u please help me