I need to get string from between two characters. I have this
S= \"10:21:35 |Manipulation |Mémoire centrale |MAJ Registre mémoire\"
a
There's String#split. Since it accepts a regular expression string, and |
is a special character in regular expressions, you'll need to escape it (with a backslash). And since \
is a special character in Java string literals, you'll need to escape it, too, which people sometimes find confusing. So given:
String S = "10:21:35 |Manipulation |Mémoire centrale |MAJ Registre mémoire";
then
String[] parts = S.split("\\|");
int index;
for (index = 0; index < parts.length; ++index) {
System.out.println(parts[index]);
}
would output
10:21:35 Manipulation Mémoire centrale MAJ Registre mémoire
(With the trailing spaces on the first three bits; trim those if necessary.)