use*_*743 -1 string android split textview
我希望每次有@时都能将TextView拆分成新的字符串.
例如,如果TextView说"你好,你@我在哪里@学校"
输出:字符串一="@我是"
字符串二="@ school"
我试过了
String[] separated = text.getText().toString().split("@ · ");
tv.setText("first " + separated[0] + " next " + separated[1] + " next " + separated[2] + " next " + separated[3]);
Run Code Online (Sandbox Code Playgroud)
String input = "hello where are you @ i am @ school"
String[] split = input.split("@");
split[0] = hello where are you
split[1] = i am
split[2] = school
Run Code Online (Sandbox Code Playgroud)
如果您的问题更多的是关于包含@符号, 如何拆分字符串,还要保留分隔符?