Here is the code to extract the number of interest if the string is ok:
string[] strList = new[] {
@"Today's Market value* 0.5 percent",
@"Today's Market value\1 0.5 percent",
@"Today's Market value \1 0.5 percent",
@"Today's Market value e 0.5 percent",
@"Today's Market value 0.5 percent",
@"Today's market value is 0.5 percent",
@"Today's market value is 0.5 percent",
@"Today's Market value is 0.5 percent"
};
foreach (string str in strList)
{
Match m = Regex.Match(str, @"(?<=Market value.*\s)(?<!Market value.*[a-zA-Z]{2}.*)\d+(\.\d+)?(?=\s.*percent)(?!.*[a-zA-Z]{2}.*percent)", RegexOptions.Singleline);
if (m.Success)
Console.WriteLine("{0} : {1}", m.Value, str);
}
Output:
0.5 : Today's Market value* 0.5 percent
0.5 : Today's Market value\1 0.5 percent
0.5 : Today's Market value \1 0.5 percent
0.5 : Today's Market value e 0.5 percent
0.5 : Today's Market value 0.5 percent
Basic idea: the number should be preceded by Market value text, anything and whitespace, but shouldn't be preceded by Market value + 2 or more sequential letters anywhere text. Also the number should be followed by whitespace, anything and percent text, but shouldn't be followed by 2 or more sequential letters anywhere + percent.