怎么判断输入的手机号是不是合法的
答案:2 悬赏:70
解决时间 2021-03-15 17:31
- 提问者网友:我喜歡係
- 2021-03-15 03:26
怎么判断输入的手机号是不是合法的
最佳答案
- 二级知识专家网友:而你却相形见绌
- 2021-03-15 05:03
如果没有其他要求,下面的就可以
^(13|15|18)\\d{9}$
表示以13或15或18开头,后面9位数字结尾
public class SortTest {
public static void main(String[] args) {
String str="13020895785";
System.out.println(str.matches("^(13|15|18)\\d{9}$"));
}
}
^(13|15|18)\\d{9}$
表示以13或15或18开头,后面9位数字结尾
public class SortTest {
public static void main(String[] args) {
String str="13020895785";
System.out.println(str.matches("^(13|15|18)\\d{9}$"));
}
}
全部回答
- 1楼网友:留下所有热言
- 2021-03-15 05:40
检查cin.fail(): #include using namespace std; int main() { int a; cin >> a; if(cin.fail()) {// 或者if(!cin) cerr << "invalid input!\n"; cin.clear(); // 对了还要加上这句 } }
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯