


Regular expression to verify whether the QQ number is entered correctly
这次给大家带来正则表达式验证qq号码是否输入正确,正则表达式验证qq号码是否输入正确的注意事项有哪些,下面就是实战案例,一起来看一下。
废话不多说了,直接给大家贴代码了,具体代码如下所示:
package 正则表达式; /*对QQ号码进行校验 要求5~15位,不能以0开头,只能是数字*/ import java.util.regex.Matcher; import java.util.regex.Pattern; public class Test { public static void main(String[] args) { // TODO Auto-generated method stub String qq = "23412312"; String regex = "[1-9][0-9]{4,14}";//第一位1-9之间的数字,第二位0-9之间的数字,数字范围4-14个之间 //String regex2 = "[1-9]\\d{4,14}";//此句也可以 boolean flag = qq.matches(regex); if(flag) System.out.println("QQ号正确"); else System.out.println("QQ号错误"); } }
相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!
推荐阅读:
The above is the detailed content of Regular expression to verify whether the QQ number is entered correctly. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to permanently block your number on iPhone? There is an option on iPhone to hide your mobile number for every call you make from the device. This can be done by permanently changing the settings on your device. To do this, you need to open the Settings app on your iPhone and select the Phone app, then you need to scroll down until you see "Show my Call ID", select that option and toggle the switch to Off . When this setting is enabled, any calls you make will not give your mobile phone number to the person you are calling. This can be a useful feature if you use your iPhone to make work calls, as many people are doing while working from home during the global pandemic. You can easily follow the above steps

Apple has integrated various features in iPhone that can be used to effectively block spam calls and unwanted text messages. These built-in tools not only enable you to protect your device from such nuisances, but also report these spammers. By doing this, you contribute to preventing future spam calls and text messages not only on your device but also on other people's devices. How to Block a Single Phone Number from Spammers on iPhone If you receive spam calls from a specific phone number on your iPhone, you can block that phone number so that you don’t receive any more calls from it. This is done on iPhone It's easy to do. To block spam calls from specific numbers on your iPhone, call

Title: How to hide the middle four digits of a mobile phone number using PHP code? In daily development work, we often involve processing users' personal information, such as mobile phone numbers. To protect user privacy, we usually hide the middle four digits of mobile phone numbers. This article will introduce how to use PHP code to implement this function to protect user information security. First of all, we need to make it clear that mobile phone numbers are sensitive information and need to be handled with caution. When displaying or storing mobile phone numbers, ensure appropriate protection to prevent

How do I hide my number on iPhone? When you want to make a call but don't want the person on the other end to know your phone number, there are two ways to hide your number on your iPhone. This can be useful when you call a business that you don't want to give out a phone number. You can set up your iPhone to permanently hide your number, which means your phone number won't be given on every call you make. The second method is to hide your number from specific calls only, which can be done by entering a number before the phone number you want to call. The number you need varies by country. How to hide your number permanently on iPhone? To permanently hide your phone number from being given when making calls, you need to change your iPhone

Python, as a high-level programming language, is easy to learn and use. Once you need to write a Python program, you will inevitably encounter syntax errors, and expression syntax errors are a common one. In this article, we will discuss how to resolve expression syntax errors in Python. Expression syntax errors are one of the most common errors in Python, and they are usually caused by incorrect usage of syntax or missing necessary components. In Python, expressions usually consist of numbers, strings, variables, and operators. most common

In C or C++, the comma "," has different uses. Here we will learn how to use them. Commas as operators. The comma operator is a binary operator that evaluates the first operand, discards the result, then evaluates the second operand and returns the value. The comma operator has the lowest precedence in C or C++. Example #include<stdio.h>intmain(){ intx=(50,60); inty=(func1(),func2());} Here 60 will be assigned to x. For the next statement, func1( will be executed first

Introduction to how to write exponential function expressions in C language and code examples What is an exponential function? The exponential function is a common type of function in mathematics. It can be expressed in the form of f(x)=a^x, where a is the base and x is the exponent. . Exponential functions are mainly used to describe exponential growth or exponential decay. Code example of exponential function In C language, we can use the pow() function in the math library to calculate the exponential function. The following is a sample program: #include

Lambda expressions in Java With the release of Java 8, lambda expressions have become one of the most concerned and discussed topics among Java developers. Lambda expressions can simplify Java programmers' tedious writing methods, and can also improve the readability and maintainability of programs. In this article, we will take a deep dive into lambda expressions in Java and how they provide a simpler and more intuitive programming experience in Java code.
