I have this String
String text = "Hello world my " + System.lineSeparator() + "name is Bob";
I also have this sentence
String sentence = "world my name is";
I have noticed that you can't find sentence
in text
with indexOf()
because of the line separator. Is there and easy and fast way to still find sentence
over a multi-line string?
EDIT:
I also need to print the string that I found as it was, meaning, If there was a System.lineSeparator()
in the text where I found sentence
, I need to print it out with that separator.
Example of i/o:
Input:
Hello world my
name is Bob
Output:
world my
name is
Thank you for all the replies!