String str ="|m4oho5kspqikkfn2may72osnfzmn3gutwzqctblzqy6rygwzxbra6bjkmy|113|70|";
String[] tokens = str.split("|");
System.out.println(tokens[0]);
System.out.println(tokens[1]);
result in white:: 0
I just need this But the only thing I want to come back is: m4oho5kspqikkfn2may72osnfzmn3gutwzqctblzqy6rygwzxbra6bjkmy
Sorry not be much English I am using Google Translator
|
is a regex protected character. You need to escape it when splitting like so:
str.split("\\|");
Regards
You can find more detailed information for regex expression in the java doc: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
There are a lot of really good examples. I strongly recommend to check them.
For literals you must use double backslash (\\) to escape the escaped character.
Cheers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.