split string only on first instance - java

前端 未结 6 634
情话喂你
情话喂你 2020-12-07 12:52

I want to split a string by \'=\' charecter. But I want it to split on first instance only. How can I do that ? Here is a JavaScript example for \'_\' char but it doesn\'t w

6条回答
  •  感情败类
    2020-12-07 13:32

    Yes you can, just pass the integer param to the split method

    String stSplit = "apple=fruit table price=5"
    
    stSplit.split("=", 2);
    

    Here is a java doc reference : String#split(java.lang.String, int)

提交回复
热议问题