Remove a random expression from string

后端 未结 7 1644
春和景丽
春和景丽 2021-01-21 06:25

I have a string/column something like this

String a = \"000003023_AggregateStopLossLimit_W x3A 973911_2012-12-22.PDF\";

I want to create a subs

7条回答
  •  [愿得一人]
    2021-01-21 07:08

    Apart from Regex issues in the code you provided, i found it less readable also.

    Try following:

    int f = a.indexOf(" ");
    int l = a.lastIndexOf("_");
    a = a.substring(0,f+1) + a.substring(l+1, a.length);
    

提交回复
热议问题