Remove part of string in Java

后端 未结 12 1778
遥遥无期
遥遥无期 2020-11-28 04:22

I want to remove a part of string from one character, that is:

Source string:

manchester united (with nice players)

Target string:

12条回答
  •  广开言路
    2020-11-28 05:03

    I would at first split the original string into an array of String with a token " (" and the String at position 0 of the output array is what you would like to have.

    String[] output = originalString.split(" (");
    
    String result = output[0];
    

提交回复
热议问题