I need to parse a few tags (their value) from am XML. This must be done by regex (don't ask me why :) )
For example:
<name>AAA</name>
<id>1234</id>
<gender>M</gender>
I know the pattern needed for each tag using regex
string name = "(?<=<name>).+?(?=</name>)";
string id = "(?<=<id>).+?(?=</id>)";
string gender = "(?<=<gender>).+?(?=</gender>)";
I just don't know how to init the Regex object to handle all of them.
I can do:
private static readonly Regex rgx1 = new Regex(name);
private static readonly Regex rgx2 = new Regex(id);
private static readonly Regex rgx3r = new Regex(gender);
but I'm guessing that's a terrible waste....
So my question is: how to init a single Regex to handle multiple patterns?
And once I did it, how to extract the values from it?
p.s: I'm programming in C# if anyone need to know....
10x alot !