I am looking for a regex pattern that changes "15 + 15/22 - 16 / 33.0" to "15 + 15 / 22.0 - 16 / 33.0" (changing integer division to division by float). My attempt:
string test = "15 + 15/22 - 16/33.0";
Regex regex = new Regex(@"(/[0-9]+[^\.])", RegexOptions.None);
test = regex.Replace(test, "$1.0");
returns a result "15 + 15/22 .0- 16/33.0.0"that has a space in "22. 0" and ends with ".0.0", which I did not expect. Who can do better?
source
share