代碼展示 判斷號碼是否正確
2019-11-05 23:56 作者:kands-code | 我要投稿

import java.util.*;
public class njava08{
? public static void main(String[]args){
? ? Scanner in = new Scanner(System.in);
? ? String text = in.next();
? ? String regex = "1\\d{10}";
? ? if(text.matches(regex)){
? ? ? System.out.println("It is a correct phone number");
? ? }else{
? ? ? System.out.println("It is not a correct phone number");
? ? }
? }
}
標簽: