Answer the question
In order to leave comments, you need to log in
How to remove everything from a string except for a specific pattern?
There is a line:
"<какой-то текст или символы>130 кг<какой-то текст или символы>"
Answer the question
In order to leave comments, you need to log in
It is possible to do this, provided that it is a single number with two or more signs:
String str = "<какой-то текст или символы>130 кг<какой-то текст или символы>";
String substr = str.replaceAll("\\d{2,}| кг", "");
String output= str.replaceAll(substr, "");
System.out.println(output);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question