當前位置:編程學習大全網 - 電腦編程 - 編寫壹個Java程序,從輸入的壹個字符串提取出數字並組合為壹個整數。

編寫壹個Java程序,從輸入的壹個字符串提取出數字並組合為壹個整數。

import?java.util.regex.Matcher;

import?java.util.regex.Pattern;

public?class?Test3?{

public?static?void?main(String[]?args)?{

String?str?=?"1229六城投84-09-六安城市建設投資有限公司";

String?temp?=?"";

String?regex?=?"\\w";

Pattern?pattern?=?Pattern.compile(regex);

Matcher?matcher?=?pattern.matcher(str);

while?(matcher.find())?{

temp?=?temp+matcher.group();

System.out.println(temp);

}

}

}

  • 上一篇:為什麽海康嵌入式實習要求那麽高
  • 下一篇:用JS編寫輸入用戶名和密碼
  • copyright 2024編程學習大全網