Extract digits from string - StringUtils Java

前端 未结 18 1189
忘掉有多难
忘掉有多难 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

    You can use the following Code to retain Integers from String.

    String text="Hello1010";
    System.out.println(CharMatcher.digit().retainFrom(text));
    

    Will give you the Following Output

    1010

提交回复
热议问题