开发者

Get value with in two separator in java

I have a string with 开发者_开发知识库"_" separator like "A_B_C_D_F". I want to fetch the value after the 2nd "_" separator to 3rd separator. In this example the value will be "C".

Please help me to do this in efficient way.


String value = yourString.split("_")[2];


Split your string based on "_" and from the resultant array, get the array[2] element. That will be the output you need. Example to get it in one line of code is -

String str = myStr.split("_")[2];


You can use String.split function like so:

String value = "A_B_C_D";
String splits = value.split("_");
String secondValue = splits[2];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜