From 902b8e09682d5447112c4b0660002e457820e7d6 Mon Sep 17 00:00:00 2001 From: PesBandi <127593627+PesBandi@users.noreply.github.com> Date: Mon, 2 Dec 2024 18:55:43 +0100 Subject: [PATCH] [Launcher][Calculator]Allow scientific notation with lowercase 'e' --- .../CalculateHelper.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateHelper.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateHelper.cs index f63be439e8de..ea1862bbf0c3 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateHelper.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateHelper.cs @@ -20,7 +20,7 @@ public static class CalculateHelper @"sinh\s*\(|cosh\s*\(|tanh\s*\(|arsinh\s*\(|arcosh\s*\(|artanh\s*\(|" + @"pi|" + @"==|~=|&&|\|\||" + - @"((-?(\d+(\.\d*)?)|-?(\.\d+))[E](-?\d+))|" + /* expression from CheckScientificNotation between parenthesis */ + @"((-?(\d+(\.\d*)?)|-?(\.\d+))[Ee](-?\d+))|" + /* expression from CheckScientificNotation between parenthesis */ @"e|[0-9]|0x[0-9a-fA-F]+|0b[01]+|[\+\-\*\/\^\., ""]|[\(\)\|\!\[\]]" + @")+$", RegexOptions.Compiled); @@ -73,11 +73,11 @@ private static string CheckScientificNotation(string input) * (-?(\d+({0}\d*)?)|-?({0}\d+)): Used to capture one of two types: * -?(\d+({0}\d*)?): Captures a decimal number starting with a number (e.g. "-1.23") * -?({0}\d+): Captures a decimal number without leading number (e.g. ".23") - * E: Captures capital 'E' + * e: Captures 'e' or 'E' * (-?\d+): Captures an integer number (e.g. "-1" or "23") */ - var p = @"(-?(\d+(\.\d*)?)|-?(\.\d+))E(-?\d+)"; - return Regex.Replace(input, p, "($1 * 10^($5))"); + var p = @"(-?(\d+(\.\d*)?)|-?(\.\d+))e(-?\d+)"; + return Regex.Replace(input, p, "($1 * 10^($5))", RegexOptions.IgnoreCase); } /*