Reputation: 21
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
Upvotes: 0
Views: 64
Reputation: 11
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.
Upvotes: 0
Reputation: 2851
|
is a regex protected character. You need to escape it when splitting like so:
str.split("\\|");
Regards
Upvotes: 3