Input " My name is Manjunath Manjunath"
Output should be
My -1,
name -1
Is -1
Manjunath -2
Hi,
How about the following?
dict =yourString.Split({" "c},StringSplitOptions.RemoveEmptyEntries).GroupBy(Function(s) s).ToDictionary(Function(g) g.Key,Function(g) g.Count)
Then, for example
String.Join(vbcrlf,dict.Select(function(d) d.Key+"-"+d.Value.ToString))
note : dict is Dictionary<string,int32>
type
Regards,
String.Join(VbCrLf,“My name is Manjunath Manjunath”.Split(" “c).Distinct().ToArray().Select(Function(a) a+”-"+Regex.Matches(“My name is Manjunath Manjunath”,a).Count.ToString).Toarray)
@“My-1
name-1
is-1
Manjunath-2”
1 Like
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.