我想将protected override void OnSourceInitialized(EventArgs e)
{
// For added compatibility, turn off hardware rendering
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
HwndTarget hwndTarget = hwndSource.CompositionTarget;
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
base.OnSourceInitialized(e);
}
这样的表达式拆分为using System.Windows.Interop;
-1*-0.8/5-5
这就是我现在使用[ '-1', '*', '-0.8', '/', '5', '-', '5' ]
对此有何建议?
答案 0 :(得分:3)
这是一个解决方案。它正确检测到-
,/
,*
,([*\/]|\b\s*-|\b\s*\+)
并接受使用空格:
var expression = "-1*-0.8/5-5";
console.log(expression.split(/([*\/]|\b\s*-|\b\s*\+)/g));
var expression = "-1 * -0.8 / (5 - 5)";
console.log(expression.split(/([*\/()]|\b\s*[-+])/g));

从 Demo on regex101 ,这是一个改进的接受括号
JOIN