dictionary - Catch strings between double quotes in a text and map their indexes into array, C# -
i have string:
string text1 = "lorem \"ipsum dolor\" quisque @ \"massa non erat\". donec auctor \"blandit\" nibh!"; i looking solution that:
1) catches words between double quotes and,
2) assigns them value of 10 so:
int[] result = {0,10,10,0,0,10,10,10,0,0,10,0} thank you.
try this:
var text1 = "lorem \"ipsum dolor\" quisque @ \"massa non erat\". donec auctor \"blandit\" nibh!"; var output = text1 .split('"') .selectmany((x, n) => x.trim().split(' ').select(y => n % 2 == 0 ? 0 : 10)) .toarray(); it produces int[] result = new [] { 0, 10, 10, 0, 0, 10, 10, 10, 0, 0, 0, 10, 0 }.
that's not you're after, fact there's . after second set of double quotes makes code think . valid word. might need think how clean string first.
Comments
Post a Comment