search
HomeCommon ProblemRegular expression does not contain

Regular expression does not contain

Jul 05, 2023 am 10:50 AM
Regular expression (regex)

Regular expressions will be used by friends no matter what kind of development they are doing, but many people don’t understand regular expressions well, and they are too lazy to read them because they are used less frequently. When using them, Just go online and look for it, but often you search online for a long time, and the results may not necessarily match what you need.

Regular expression does not contain

Regular expressions will be used by friends no matter what kind of development they are doing, but many people don’t understand regular expressions well, and because of the frequency of use Because it is relatively low and I am too lazy to look at it, I just go online to look for it when I want to use it. However, I often search online for a long time, and the results may not necessarily match what I need.

Number regularity

1. Pure digital regularity: ^[0-9]*$

2. Numbers with n digits regularity: ^\d{n} $

3. Regular rules with at least n digits: ^\d{n,}$

4. Regular rules with digits between m-n digits: ^\d{m,n }$

5. Matching integers (does not distinguish between positive and negative numbers): ^-?[1-9]d*$

6. Matching negative integers: ^-[1-9] d*$

String regular expression

1, Pure English letter regular expression (not case-sensitive): ^[A-Za-z] $

2, Regular rules for pure English uppercase letters: ^[A-Z] $

3. Regular rules for pure English lowercase letters: ^[a-z] $

4. Regular rules for only numbers and 26 English letters: ^[A-Za-z0-9] $

5. The character length is between m-n characters: ^.{m,n}$

6. It starts with a letter, The length is between 6 and 18, and can only contain letters, numbers and underscores: ^[a-zA-Z]\w{5,17}$

7. It starts with a letter and has a length between 6 and 18. Between them, they can only contain letters and numbers without underscores: ^[a-zA-Z][a-zA-Z0-9]{4,15}$

8. They must and can only contain numbers. The regular expression of sum letters: ^(?![0-9] $)(?![a-zA-Z] $)[0-9A-Za-z]{6,10}$

with Let’s talk about this as an example

^ means the starting position of a line

(?![0-9] $) means not all numbers

(?![a- zA-Z] $) means it is not all letters

[0-9A-Za-z] {6,10} means it consists of 6-10 digits or letters

$ Matching lines The three conditions of the ending position

determine that this expression must contain numbers and letters, it can only contain numbers and letters, and the character length is between 6-10 digits.

9. ID number (only 15 or 18 digits are verified) regular: ^d{15}|d{18}$

Let’s explain the rules a little (you can follow the above Examples verify each other and enhance understanding)

\w: represents numbers, letters and underlines.

\d: Represents only numbers.

^: The starting position of the string. If it is inside [ ], it means "not", which means excluding the content contained in [ ]

^n: It means it must start with n string.

$: The end position of the string.

?=n: Indicates that the string n is followed immediately.

?!n: Indicates that the string n is not followed immediately.

The above is the detailed content of Regular expression does not contain. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software