私の入力は次のようなものです
String str = "-1.33E+4-helloeeee+4+(5*2(10/2)5*10)/2";
私は次のように出力したい:
1.33E+4
helloeeee
4
5
2
10
2
5
10
2
しかし、私は出力を次のように取得しています
1.33, 4, helloeeee, 4, 5, 2, 10, 2, 5, 10, 2
「1.33e+4」を分割した後の指数値が完全に欲しい
ここに私のコードがあります:
String str = "-1.33E+4-helloeeee+4+(5*2(10/2)5*10)/2";
List<String> tokensOfExpression = new ArrayList<String>();
String[] tokens=str.split("[(?!E)+*\\-/()]+");
for(String token:tokens)
{
System.out.println(token);
tokensOfExpression.add(token);
}
if(tokensOfExpression.get(0).equals(""))
{
tokensOfExpression.remove(0);
}