I want to split my string with the following symbols: +, -, *, / but .split function only accepts one

android, arrays, java, split, string

Solution

String.split takes a regex to split on, so you can simply:

 String[] array = myString.split("\\+|\\-|\\*|\\/");

please give me some feedback

Hope that helps .

Problem

Currently, this is my code: ``` public void setEquals(View v){ EditText txtDisplay = (EditText) findViewById(R.id.txtDisplay); display = txtDisplay.getText().toString(); String[] strArrDisplay = display.split("\\+"); txtDisplay.setText(String.valueOf(strArrDisplay[0])); ``` My current code can only split successfully the plus sign(+). I want the string to be split if there is a plus, minus, multiply, or divide signs. Let's say the input would be: 123+5-2 so the desired output should be: ``` strArrDisplay[0] = "123" strArrDisplay[1] = "5" strArrDisplay[2] = "2" ```

Original source