Extract digits from string - StringUtils Java

前端 未结 18 1237
忘掉有多难
忘掉有多难 2020-12-01 09:06

I have a String and I want to extract the (only) sequence of digits in the string.

Example: helloThisIsA1234Sample. I want the 1234

It\'s a given that the s

18条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-01 09:31

            String line = "This order was32354 placed for QT ! OK?";
            String regex = "[^\\d]+";
    
            String[] str = line.split(regex);
    
            System.out.println(str[1]);
    

提交回复
热议问题