Repository: microsoft/PowerToys
File: src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateHelper.cs (C#)

Code before:
            return true;
        }

        public static string FixHumanMultiplicationExpressions(string input)
        {
            var output = CheckScientificNotation(input);
            output = CheckNumberOrConstantThenParenthesisExpr(output);
            output = CheckNumberOrConstantThenFunc(output);
            output = CheckParenthesisExprThenFunc(output);
            output = CheckParenthesisExprThenParenthesisExpr(output);
            output = CheckNumberThenConstant(output);
            output = CheckConstantThenConstant(output);
            return output;
        }

        private static string CheckScientificNotation(string input)
        {
            /**
             * NOTE: Anywhere you see a "{0}", that is meant to be replaced by the user's decimal separator.
             *
             * Regex explanation:
             * (-?(\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'
             * (-?\d+{0}?\d*): Captures an integer number (e.g. "-1" or "23")
             */
            var p = @"(-?(\d+({0}\d*)?)|-?({0}\d+))E(-?\d+)";

            // If the decimal separator is a ".", we also have to insert a backslash.
            if (CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator == ".")
            {
                p = string.Format(CultureInfo.CurrentCulture, p, @"\.");
            }
            else
            {
                p = string.Format(
                    CultureInfo.CurrentCulture,
                    p,
                    CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
            }

            return Regex.Replace(input, p, "($1 * 10^($5))");
        }

        /*
         * num (exp)
         * const (exp)
         */
        private static string CheckNumberOrConstantThenParenthesisExpr(string input)
        {

Review comment (suggestion):
```suggestion
             * (-?\d+): Captures an integer number (e.g. "-1" or "23")
```

Code after:
            return true;
        }

        public static string FixHumanMultiplicationExpressions(string input)
        {
            var output = CheckScientificNotation(input);
            output = CheckNumberOrConstantThenParenthesisExpr(output);
            output = CheckNumberOrConstantThenFunc(output);
            output = CheckParenthesisExprThenFunc(output);
            output = CheckParenthesisExprThenParenthesisExpr(output);
            output = CheckNumberThenConstant(output);
            output = CheckConstantThenConstant(output);
            return output;
        }

        private static string CheckScientificNotation(string input)
        {
            /**
             * NOTE: By the time the expression gets to us, it's already in English format.
             *
             * Regex explanation:
             * (-?(\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'
             * (-?\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))");
        }

        /*
         * num (exp)
         * const (exp)
         */
        private static string CheckNumberOrConstantThenParenthesisExpr(string input)
        {
            var output = input;
            do
            {
                input = output;
                output = Regex.Replace(input, @"(\d+|pi|e)\s*(\()", m =>
                {
                    if (m.Index > 0 && char.IsLetter(input[m.Index - 1]))
                    {
                        return m.Value;
                    }

                    return $"{m.Groups[1].Value} * {m.Groups[2].Value}";
                });
            }