我正在尋找替代的C#拆分,我可以傳遞一個字符串數組。JavaScript的請求表達式
string[] m_allOps = { "*", "/", "+", "-", "<", ">", "=", "<>", "<=", ">=", "&&", "||" };
string s = "@ans = .707 * sin(@angle)";
string[] tt = s.Split(m_allOps,StringSplitOptions.RemoveEmptyEntries); // obtain sub string for everything in the equation that is not an operator
我敢肯定,有一個使用regEx的解決方案,但我似乎無法弄清楚如何構造正則表達式。
你想要輸出什麼? –
@ ans,.707,sin(@angle) – MtnManChris
請參閱[此演示](https://jsfiddle.net/xtsoLpvd/) –