Splitting a String in Java with underscore as delimiter

后端 未结 7 1013
野的像风
野的像风 2021-01-13 00:49

I have the following String (This format for the string is generic)

abc_2012-10-18-05-37-23_prasad_hv_Complete

I want to extract only

相关标签:
7条回答
  • 2021-01-13 01:32

    You can also use regular expression. That will result in something like that:

    Pattern pattern = Pattern.compile(".*[0-9]_(.*)_Complete");
    Matcher matcher = pattern.matcher("abc_2012-10-18-05-37-23_prasad_hv_Complete");
    matcher.find();
    String group = matcher.toMatchResult().group(1);
    
    0 讨论(0)
提交回复
热议问题