Remove part of string in Java

后端 未结 12 1742
遥遥无期
遥遥无期 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 04:59

    String Replace

    String s = "manchester united (with nice players)";
    s = s.replace(" (with nice players)", "");
    

    Edit:

    By Index

    s = s.substring(0, s.indexOf("(") - 1);
    

提交回复
热议问题