Remove part of string in Java

后端 未结 12 1756
遥遥无期
遥遥无期 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:47

    Using StringUtils from commons lang

    A null source string will return null. An empty ("") source string will return the empty string. A null remove string will return the source string. An empty ("") remove string will return the source string.

    String str = StringUtils.remove("Test remove", "remove");
    System.out.println(str);
    //result will be "Test"
    

提交回复
热议问题