Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用字符串作为分隔符拆分字符串_Java_Android - Fatal编程技术网

Java 使用字符串作为分隔符拆分字符串

Java 使用字符串作为分隔符拆分字符串,java,android,Java,Android,是否可以使用字符串作为分隔符拆分字符串?如果是,如何进行 例如: String myString = "hello_world<;>goodbye<;>foo"; myString.split("<;>"); //returns "hello_world", "goodbye" and "foo" String myString=“hello\u WorldGoodbyefo”; myString.split(“”); //返回“hello_world”、

是否可以使用字符串作为分隔符拆分字符串?如果是,如何进行

例如:

String myString = "hello_world<;>goodbye<;>foo";
myString.split("<;>");

//returns "hello_world", "goodbye" and "foo"
String myString=“hello\u WorldGoodbyefo”;
myString.split(“”);
//返回“hello_world”、“再见”和“foo”

是的,与您的代码中的示例完全相同。

您问题中的示例完全有效,但这可能是巧合。请记住,
String.split(…)
方法接受正则表达式参数,而不是字符串分隔符


查看此处的RegEx文档:

那么您的问题是…?很抱歉,但我认为这是不可能的,因为我来自.Net世界,在它里面是不可能的……如果我可以删除这个问题,我会这样做。但我不能,因为有答案^^作为将来的参考,谷歌和谷歌对于这样的问题都很有帮助。你的问题摘要的确切文本的第一个结果是答案。@yshavit我能有证据吗?因为我找了又没找到。所以我认为这是不可能的,所以我问了这个问题。