How to remove empty results after splitting with regex in Java?

前端 未结 7 1604
臣服心动
臣服心动 2021-01-17 16:02

I want to find all numbers from a given string (all numbers are mixed with letters but are separated by space).I try to split the input String but when check the result arra

7条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-17 16:25

    Pattern reg = Pattern.compile("\\D+");
    // ...
    

    results in:

    0085
    223
    9349
    

提交回复
热议问题