I'm trying to extract double from a string like this :
Regex regex = new Regex(@"^-?\d+(?:\.\d+)?");
Match match = regex.Match(mystring);
double number = double.Parse(match.Value);
As Markus indicated, if you want it to match regardless of where the double is in the string, simply remove that ^ which indicates that it is checking the start of the string:
(Note that this may result in more than one match.)
If you want it to match only when the string ends in the double, add a $ to the end:
Online regex validators are incredibly useful, and some will break down which each individual component does. It's a lot faster to test out a regex this way instead of recompiling repeatedly until you get it right.
EDIT: As Wiktor pointed out, this site doesn't actually validate .NET syntax regex. Therefore, it may not be suitable for certain types of regular expressions, but many common scenarios will be identical.