java从字符串中提取数字

时间:2025-03-01 14:10:30

/**

 * 从字符串文本中获得数字

 

*@param

 text

 

*@return

  

 

*/

  

 

publicstatic

 List<Long>

 getDigit(String text) {

 

List<Long>

 digitList =new

 ArrayList<Long>();

  

 

Pattern p=

 ("(\\d+)");

  

 

Matcher m=

 (text);

 

while

 (()) {

 

String find=

 (1).toString();

 

((find));

 

}return

 digitList;

 

}