I need your help because I have a regular expression to delete two or more blank spaces, but I have tried in several ways and I can not get the expected result, you can guide me please.
Case No. 1
String texto = " 95716 B VO 21513836 269 60 S 50.40 3024.00 SI DCBO040818BLA";
texto = texto.replaceAll("\s+"," ");
Case No. 2
String texto = " 95716 B VO 21513836 269 60 S 50.40 3024.00 SI DCBO040818BLA";
texto = texto.replaceAll("\s"," ");
Case No. 3
String texto = " 95716 B VO 21513836 269 60 S 50.40 3024.00 SI DCBO040818BLA";
texto = texto.replaceAll(" +"," ");
Case No. 4
String texto = " 95716 B VO 21513836 269 60 S 50.40 3024.00 SI DCBO040818BLA";
texto = texto.replaceAll("\s+"," ").trim();
Case No. 5
String texto = " 95716 B VO 21513836 269 60 S 50.40 3024.00 SI DCBO040818BLA";
texto = texto.replaceAll("\s+"," ").replaceAll("^\s*","").replaceAll("\s*$","");
Case No. 6
String texto = " 95716 B VO 21513836 269 60 S 50.40 3024.00 SI DCBO040818BLA";
texto = texto.replace(" "," ");
Expected result
String texto = "95716 B VO 21513836 269 60 S 50.40 3024.00 SI DCBO040818BLA";