Location="Theater=1, Name=regal, Area=Area1"
Location="Theater=34, Name=Karm, Area=Area4445"
etc. I have to extract the name bits from the string. For example, in Here I have to extract the text’regal’ and group the query. Then the result is displayed as
Name=regal Count 33
Name=Karm Count 22
I am trying to solve this problem:
Collection.Location.GroupBy(????);(What to add here)
This is the shortest and most precise method NS?
string[] Location = {
"Theater=2, Name=regal, Area=Area1",
"Theater=2, Name=regal, Area=Area1",
"Theater=34, Name=Karm, Area=Area4445"
};
var test = Location.Select(
x => Regex.Match(x, "^. *Name=(.*),.*$")
.Groups[1].Value)
.GroupBy(x => x)
.Select(x=> new {Name = x.Key, Count = x.Count()));
Query the result of the test string
I have a collection. coll There are strings:
Location="Theater=1, Name=regal, Area=Area1"
Location="Theater=34 , Name=Karm, Area=Area4445"
etc. I have to extract the name bits from the string. For example, here I have to extract the text’regal’ and group the query. Then the result is displayed as
Name=regal Count 33
Name=Karm Count 22
I am trying to solve this problem:
Collection .Loca tion.GroupBy(????);(What to add here)
Is this the shortest and most precise method?
Another Linq Regex method:
string[] Location = {
"Theater=2, Name=regal, Area=Area1",
"Theater=2, Name=regal, Area=Area1",
"Theater=34, Name=Karm, Area=Area4445 "
};
var test = Location.Select(
x => Regex.Match(x, "^.*Name=(.*),.*$" )
.Groups[1].Value)
.GroupBy(x => x)
.Select(x=> new {Name = x.Key, Count = x.Count() });
Query the result of the test string