-2

I am using the following code to try and start a new line after the end of a sentence, so for example "2.Put the turkey" would start a new line. But this doesn't happen. What have I done wrong?

"1.To make the Mexican seasoning, mix the ingredients together in a bowl. 2.Put the turkey mince and Mexican seasoning into a large bowl and mix well with your hands. 3.Heat half the olive oil in a frying pan over a high heat and cook the onions, spring onions and peppers for 3 minutes. Add a pinch of salt and pepper. Remove the vegetables from the pan and set aside.

    method.replaceAll("\\.\\s?", "\\.\n");
    methodText = findViewById(R.id.methodText);
    methodText.setText(method);
  • 1
    Strings are immutable, so `replaceAll` **returns** the new string: `method = method.replaceAll("\\.\\s?", ".\n");` – Andreas Oct 04 '20 at 11:09
  • Duplicate of [How to replace a substring of a string](https://stackoverflow.com/q/16702357/5221149) – Andreas Oct 04 '20 at 11:11

1 Answers1

0

try this....

String method="1.To make the Mexican seasoning, mix the ingredients together in a bowl. 2.Put the turkey mince and Mexican seasoning into a large bowl and mix well with your hands. 3.Heat half the olive oil in a frying pan over a high heat and cook the onions, spring onions and peppers for 3 minutes. Add a pinch of salt and pepper. Remove the vegetables from the pan and set aside.";
        String m=method.replaceAll("\\. ", ".\n");
Deepak Maurya
  • 67
  • 1
  • 9