How to break such a string "Ivanov I. teacher" into two substrings using split :

  1. Ivanov I.I.
  2. teacher

    1 answer 1

    If there is definitely no space between the initials, then it is possible by a dot and a space. True point after the last initial disappears, but you can manually add:

     String[] arr = "Иванов И.И. преподаватель".split(". "); arr[0]+="."; 
    • and what to do in the following case? The line "Ivanov I.I. Admin. In the IS (lek.) S-204 (1-11)" is given. It is necessary to obtain the following words separately: 1) Ivanov I.I. 2) Admin. in IS 3) lek 4) C-204 5) 5-11 - Samur
    • one
      here you get another question already. I can have any string how do I get the right one - MrGarison
    • one
      @Samur, the most correct solution is not to receive data in this form, because such a line can be parsed programmatically - ad - YuriySPb
    • @ ЮрийСПб and if there is no other possibility? - Samur
    • @Samur, well, in this case it is necessary either to write a hellish regular season (it is extremely difficult, you need a special one here) or write an hellish algorithm, for example, first by the second entry "." Cut the string, then by the first "(", " ) "etc - JuriySPb