當前位置:編程學習大全網 - 電腦編程 - java中怎麽截取字符串中的數字

java中怎麽截取字符串中的數字

java中截取字符串中的數字方法有很多,例如用正則表達式。試壹試下面的演示程序吧。

public?class?SplitTest

{

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

{

String?input?=?"jdiwo3495jis90.5jsie4dss56djiw9";

String?regex?=?"\\d+(\\.\\d+)?";

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

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

while(matcher.find())

{

System.out.println(matcher.group());

}

}

}

  • 上一篇:精雕9.5五軸刀路很多紋路不平整
  • 下一篇:VBA中對象,窗體,模塊和類模塊分別有什麽用啊
  • copyright 2024編程學習大全網