I need your help because I have a regular expression for all the blanks at the beginning and end of a word, but I have tried in several ways and I can not get the expected result, can you please guide me.
Word 1:
4. numero de identificación
Word 2:
3. nombre
Regular Expression
String texto = texto.replaceAll("^\s{2,}|$\s|\s+(?=\s)", "")
Tests conducted:
Test No. 1a
String textoA = "3. nombre ";
String resultadoA = textoA.trim(); **resultado:** '3. nombre
Test No. 1b
String textoA = "3. nombre ";
String resultadoA = textoA .replaceAll("^\s{2,}|$\s|\s+(?=\s)", "");
Expected result:
Word 1:
4. numero de identificación
Word 2:
3. nombre