I found following pattern from RegexLibrary, and i don't know how use Match to get Re and Im values. I'm new in Regex
. Is it a correct way to get data from a pattern?
If it's true, I need some sample code!
This is what i think it should be:
public static complex Parse(string s)
{
string pattern = @"([-+]?(\d+\.?\d*|\d*\.?\d+)([Ee][-+]?[0-2]?\d{1,2})?[r]?|[-+]?((\d+\.?\d*|\d*\.?\d+)([Ee][-+]?[0-2]?\d{1,2})?)?[i]|[-+]?(\d+\.?\d*|\d*\.?\d+)([Ee][-+]?[0-2]?\d{1,2})?[r]?[-+]((\d+\.?\d*|\d*\.?\d+)([Ee][-+]?[0-2]?\d{1,2})?)?[i])";
Match res = Regex.Match(s, pattern, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
// What should i do here? The complex number constructor is complex(double Re, double Im);
// on error...
return complex.Zero;
}
Thanks in advance!