I want to extract some string data from a given file. File got structure such as:
name, catg, {y:2006, v:1000, c:100, vt:1}, {y:2007, v:1000, c:100, vt:1},.. {..}..
.
I want to extract next values:
- name;
- catg;
- numbers after
y
,v
,c
,vt
labels;
I used the next regexes:
@"(?<name>\w+), (?<cat>\w+)"
for extraction of the first two items;@"(?:\{y:(?<y>\d+), +v:(?<v>\d+), +c:(?<c>\d+), +vt:(?<vt>\d+)\}, ?)+"
for extraction of other values enclosed in curly brackets.
I concatenated those two and made a test in regex tester. But as expected I get only one set of extracted numbers. And I need result from the other part ({y:2007, v:1000, c:100, vt:1}
). Moreover there could be more than two parts.
How do I fix my regex? And then how do I collect all number sets from corresponding parts.
Here's fixed regex (you need to specify IgnorePatternWhitespace option):
And here's usage: