Of course, a stupid question, but still. I can not figure it out. There is a line:

String s = "бла бла-бла сывSU"; 

So the question is how to separate in java "blah blah syv" from SU? Before "SU" can be any text characters and so on. "SU" is the main identifier.

Thank you in advance.

And again, sorry for the stupid questions.

  • String bla="бла бла-бла сыв"; String su= "SU"; For a more general answer, you need to define it formally than these lines are different from each other - default locale
  • substring () Allows you to get some content There are two forms of the method. In the first case, you need to specify the index of the beginning of the position from which you want to get the substring. In the second variant, the starting index and the ending index are indicated, if you need to get the text from the middle of the line. Naturally you still have to determine the position of the SU - Kleimosc
  • @Kleimosc needs to get everything after the "SU" inclusive. What index do I need to specify in this case? Thank. - Philipesko
  • @defaultlocale I may not have defined the task. Formally, before the "SU" can be anything, you need to get rid of it. The question is how!? Thank. - Philipesko
  • one
    If all that is used after that is String s = str.substring (str.lastIndexOf ("SU"); - Kleimosc

1 answer 1

@Kleimosc answered the question. The correct decision was:

 String s= str.substring(str.lastIndexOf("SU"); 

After this operation, all that remains after SU including SU.