Split string and trim every element

后端 未结 5 947
失恋的感觉
失恋的感觉 2021-02-01 14:39

Is there any library API or regex pattern to split a String on some delimiter and automatically trim leading and trailing spaces from every element without having to loop the el

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-01 15:21

    What about just doing a replaceall before splitting?

    str.replaceall("\\s*#\\s*","#").split()
    

提交回复
热议问题