金融AIGC研究
优质  高效     
优质的技术交付服务 迅捷的办事效率
我们专注品质与服务   决胜制高点  细节决定成败
Runoff commanding heights Detail decides success or failure
The commanding heights of
the details determine success or failure
技术动态
DETAIL
code performance review
来源:互联网 | 作者:business-101 | 发布时间: 2024-07-17 | 198 次浏览 | 分享到:


package com.example.demo.acontest;


public class NumberGain {


public static String getNumber(String input) {

String num=input.replaceAll("[a-z|A-Z]", "");

if(num.length()<1)return "";

String[] parts=num.split("\.");

// System.out.println(parts[0]+":"+parts.length);

num=parts[0];

if(parts.length>1) {

// System.out.println(parts[1]);

if(parts[1].length()==0) {

num+=".00";

}else if(parts[1].length()==1) {

num+="."+parts[1]+"0";

}else {

num+="."+(parts[1].substring(0,2));

}

}else {

num+=".00";

}

return num;

}

public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.println("abv"+" is "+getNumber("abc"));

System.out.println("abv12"+" is "+getNumber("abv12"));

System.out.println("abv12."+" is "+getNumber("abv12."));

System.out.println("abv12.1"+" is "+getNumber("abv12.1"));

System.out.println("abv12.12"+" is "+getNumber("abv12.12"));

System.out.println("abv12.123"+" is "+getNumber("abv12.123"));


System.out.println("abv.123"+" is "+getNumber("abv.123"));

System.out.println("abv.188"+" is "+getNumber("abv.188"));

}


}