I would go for a regular expression.
You can find some informations
here.
And there is a tool,
Expresso, most useful to build your expressions and test them against as much entries as you want/need to.
Having a look at regular expressions is worth the additional learning time ; you will find they can be handy in many situations.
For your question, it would be (updated for variable lengths and any alphanumeric character) :
^(?:[\w]+\([\w]+\))\((?<NamedValue>[\d]+(?:\.[\d]+)?)\)$
Which describes the chain as :
Begin of line - One or more letters, followed by one or more letters enclosed in parenthesis, followed by a named capture group enclosed in parenthesis. This named capture group is composed of one or more digits, followed or not by a point and one or more digits - End of line
You can obtain the string representation of your double in
NamedValue
.
You can convert it to double by using the method hzawary told you, but passing only the
NamedValue
you got. It can be great to use
Double.TryParse()
to handle problematic entries.
double d;
bool ok = double.TryParse(yourMatch.Group["NamedValue"].Value, out d);
Hope this helps.