I think you may be writing the value of
quantity
and value of
price
in the above format like
image 45.5(35.45)
, in which case the following
Regex
pattern can be used to retrieve the
quantity
and
price
part.
string qtyPrice = @"image 45.5(35.45) ";
Match match = Regex.Match(qtyPrice,@"\s+([\d.]+)\s*\(\s*([\d.]+)\s*\)",
RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
double quantity;
decimal price;
if (match.Success){
double.TryParse(match.Groups[1].Value,out quantity);
decimal.TryParse(match.Groups[2].Value,out price);
}
In the above code the pattern
@"\s+([\d.]+)\s*\(\s*([\d.]+)\s*\)
matches the value between space and ( into the
Groups[1]
and matches the value between ( and ) into
Groups[2]