I am trying to use a regular expression like this:
string Size= "10.5M"; Match m = null; if ((m = (new Regex(@"(\d)([MGTP%]?)", RegexOptions.IgnoreCase).Match(Size))).Success) { Size = m.Groups[1].ToString(); if (m.Groups.Count > 1) SizeUnit = m.Groups[2].ToString(); // if not given, SizeUnit is percentage } But when I pass the value, Size shows as 10, and SizeUnit as "" instead of the expected Size = 10.5 and SizeUnit = M
(\d+\.\d+)([MGTP%]?)