Extract digits from string - StringUtils Java
问题 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 sequence of digits will occur only once within the string but not in the same position. (for those who will ask, I have a server name and need to extract a specific number within it) I would like to use the StringUtils class from Apache commomns. Thanks! 回答1: Use this code numberOnly will contain your desired output. String str=