无法在Java中正确拆分字符串

时间:2013-02-28 11:15:31

标签: java regex string split pattern-matching

我有像(x == y), (t != s), (a = b + c)这样的字符串。现在,我需要左侧字母xta和正确的字母ysb,{{ 1}}。

为此,我正在做以下事情:

c

现在,此代码适用于(a = b + c)等方程式。对于前两个方程,它只返回左手变量(x,t),而不是右手变量(y,s)。

我在这里做错了什么?

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

对于初学者: - 第二个getVars(eqn[0]));必须是getVars(eqn[1]));

while(//{condition}){
  eqn = stmnt.split("=");
  getVars(eqn[0])); // first while round should return x, then t, and so on. 
  getVars(eqn[1])); // first while round should return y, then s, then b, c.
}