How to remove all String text before equals ('=') sign Java

前端 未结 4 907
自闭症患者
自闭症患者 2021-01-21 07:51

I\'d like to parse a string so I can build an XML document.

I have:

String value = \"path=/Some/Xpath/Here\";

I\'ve parsed it this way

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-21 08:52

    if you are looking into performance you should avoid usage of split since it uses regular-expressions which is a bit oversized for such a simple problem. if you just want to remove "path=" and you are sure that your string always starts that way you could go with the following:

    String s = "path=/Some/Xpath/Here";
    String prefix = "path=";
    String result = s.substring(prefix.length);
    

提交回复
热议问题