Answer the question
In order to leave comments, you need to log in
How to find it in a string?
In general, it is necessary that Value1, value2, value3 be written to different variables. For example, a string is passed to jav'e Value1(Value2, Value3)
and it is necessary for Java to understand that it is necessary to write the word before the brackets into a variable, there are 2 variables in brackets, separated by commas. I hope I explained everything clearly
Answer the question
In order to leave comments, you need to log in
String s = "Value1(Value2, Value3)";
Scanner scanner = new Scanner(s);
scanner.useDelimiter("\\(|,|\\)");
List<String> tokens = new ArrayList<>();
while (scanner.hasNext()) {
tokens.add(scanner.next().trim());
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question