How to split a String based on first occurence?

java, regex

Solution

You can use the second parameter of `split` as seen in the Java doc

If you want the split to happen as many times as possible, use:

"test1=test1=test1=".split("=", 0);    // ["test1","test1","test1"]

If you want the split to happen just once, use:

"test1=test1=test1=".split("=", 2);    // ["test1","test1=test1="]

Problem

How can I split a String based on the first equals sign `"="`? So `test1=test1` should be transformed into `test1, test1` (as an array) `"test1=test1".split("=")` works fine in this example. But what about the CSV string ``` test1=test1= ```

Original source

Related problems