Java – how do I split strings based on the first occurrence?
•
Java
How do I split a string based on the first equal sign "="?
therefore
TEST1 = TEST1
Should be converted to test1, test1 (as an array)
“test1 = test1”. Split ("=") works in this example
But what about CSV strings?
test1=test1=
Solution
You can use the second parameter of the split, as shown in the Java doc
If you want the split to occur as many times as possible, use:
"test1=test1=test1=".split("=",0); // ["test1","test1","test1"]
If you want the split to occur only once, 2)// ["test1","test1=test1="]
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码