Skip to content

Commit f557f31

Browse files
committed
[PTRun][Calculator]Allow scientific notation with lowercase 'e' (microsoft#36187)
1 parent 28247e9 commit f557f31

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateHelper.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static class CalculateHelper
2020
@"sinh\s*\(|cosh\s*\(|tanh\s*\(|arsinh\s*\(|arcosh\s*\(|artanh\s*\(|" +
2121
@"pi|" +
2222
@"==|~=|&&|\|\||" +
23-
@"((-?(\d+(\.\d*)?)|-?(\.\d+))[E](-?\d+))|" + /* expression from CheckScientificNotation between parenthesis */
23+
@"((-?(\d+(\.\d*)?)|-?(\.\d+))[Ee](-?\d+))|" + /* expression from CheckScientificNotation between parenthesis */
2424
@"e|[0-9]|0x[0-9a-fA-F]+|0b[01]+|[\+\-\*\/\^\., ""]|[\(\)\|\!\[\]]" +
2525
@")+$",
2626
RegexOptions.Compiled);
@@ -73,11 +73,11 @@ private static string CheckScientificNotation(string input)
7373
* (-?(\d+({0}\d*)?)|-?({0}\d+)): Used to capture one of two types:
7474
* -?(\d+({0}\d*)?): Captures a decimal number starting with a number (e.g. "-1.23")
7575
* -?({0}\d+): Captures a decimal number without leading number (e.g. ".23")
76-
* E: Captures capital 'E'
76+
* e: Captures 'e' or 'E'
7777
* (-?\d+): Captures an integer number (e.g. "-1" or "23")
7878
*/
79-
var p = @"(-?(\d+(\.\d*)?)|-?(\.\d+))E(-?\d+)";
80-
return Regex.Replace(input, p, "($1 * 10^($5))");
79+
var p = @"(-?(\d+(\.\d*)?)|-?(\.\d+))e(-?\d+)";
80+
return Regex.Replace(input, p, "($1 * 10^($5))", RegexOptions.IgnoreCase);
8181
}
8282

8383
/*

0 commit comments

Comments
 (0)