我希望每次有@。
时能够将TextView拆分成新的字符串E.g。如果TextView说“你好,你在哪里@我是@学校”
输出:字符串一=“@我是”
String two =“@ school”
我试过了
String[] separated = text.getText().toString().split("@ · ");
tv.setText("first " + separated[0] + " next " + separated[1] + " next " + separated[2] + " next " + separated[3]);
答案 0 :(得分:5)
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
如果你的问题更多的是关于包含@符号, How to split a string, but also keep the delimiters?