Home Backend Development PHP Tutorial Email Regular Expressions and URL Regular Expressions_PHP Tutorial

Email Regular Expressions and URL Regular Expressions_PHP Tutorial

Jul 13, 2016 pm 04:58 PM
email url and about practical supply regular of expression verify

Email regular expression and URL regular expression Here are two regular expressions for email regular expression and URL regular expression verification, which are very practical. The regular expression for email can get all the email addresses in the content, and the same is true for URL address regular expressions. You can get all the email addresses in the content. Save and extract all URL addresses starting with http.

email regular expression and url regular expression
Here are two regular expressions for email regular expression and url regular expression verification, which are very practical. The regular expression for email can get all the email addresses in the content, and the same goes for the url address regular expression, which can be used to get all the email addresses in the content. Save and extract all URL addresses starting with http.
*/

$str_arr = array(
"mymail@bKjia.c0m",
"my_mail@bKjia.c0m",
"my-mail@bKjia.c0m",
"my.mail@site.com.cn",
"mymail@site.com.ccoomm",
"mymail@site.cn",
"mymail@@@lsite.com",
"mymail@site",
"mymail@bKjia.c0m",
"my2007@bKjia.c0m",
"163mail_for-me777@bKjia.c0m",
);

$patt_email = "/^[_a-za-z0-9-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,4}$ /";

foreach ($str_arr as $str)
{
echo "String '$str': Yes";
If (preg_match($patt_email, $str))
{
echo "Legitimate email format";
echo "
";
echo "
";
}
else
{
echo "Illegal email format";
echo "
";
echo "
";
}
}

// 17. URL regular expression.

$str_arr = array(
"http://www.bKjia.c0m",
"www.bKjia.c0m",
"http://www.bKjia.c0m/abc/123.html",
"//bKjia.c0m",
":www.bKjia.c0m"
);

$patt_url = "/^(http://)?[a-za-z0-9]+(.[a-za-z0-9]+)*.+$/";

foreach ($str_arr as $str)
{
echo "String '$str': Yes";
If (preg_match($patt_url, $str))
{
echo "Legal URL format";
echo "
";
echo "
";
}
else
{
echo "Illegal url format";
echo "
";
echo "
";
}
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631362.htmlTechArticleEmail regular expression and URL regular expression Here are two types of verification of Email regular expression and URL regular expression Regular expressions are very practical. Regarding email regular expressions, you can convert the content...
Statement of this Website
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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to set up the keyboard boot function on a GIGABYTE motherboard (enable keyboard boot mode on GIGABYTE motherboard) How to set up the keyboard boot function on a GIGABYTE motherboard (enable keyboard boot mode on GIGABYTE motherboard) Dec 31, 2023 pm 05:15 PM

How to set up keyboard startup on Gigabyte's motherboard. First, if it needs to support keyboard startup, it must be a PS2 keyboard! ! The setting steps are as follows: Step 1: Press Del or F2 to enter the BIOS after booting, and go to the Advanced (Advanced) mode of the BIOS. Ordinary motherboards enter the EZ (Easy) mode of the motherboard by default. You need to press F7 to switch to the Advanced mode. ROG series motherboards enter the BIOS by default. Advanced mode (we use Simplified Chinese to demonstrate) Step 2: Select to - [Advanced] - [Advanced Power Management (APM)] Step 3: Find the option [Wake up by PS2 keyboard] Step 4: This option The default is Disabled. After pulling down, you can see three different setting options, namely press [space bar] to turn on the computer, press group

How to verify signature in PDF How to verify signature in PDF Feb 18, 2024 pm 05:33 PM

We usually receive PDF files from the government or other agencies, some with digital signatures. After verifying the signature, we see the SignatureValid message and a green check mark. If the signature is not verified, the validity is unknown. Verifying signatures is important, let’s see how to do it in PDF. How to Verify Signatures in PDF Verifying signatures in PDF format makes it more trustworthy and the document more likely to be accepted. You can verify signatures in PDF documents in the following ways. Open the PDF in Adobe Reader Right-click the signature and select Show Signature Properties Click the Show Signer Certificate button Add the signature to the Trusted Certificates list from the Trust tab Click Verify Signature to complete the verification Let

Why NameResolutionError(self.host, self, e) from e and how to solve it Why NameResolutionError(self.host, self, e) from e and how to solve it Mar 01, 2024 pm 01:20 PM

The reason for the error is NameResolutionError(self.host,self,e)frome, which is an exception type in the urllib3 library. The reason for this error is that DNS resolution failed, that is, the host name or IP address attempted to be resolved cannot be found. This may be caused by the entered URL address being incorrect or the DNS server being temporarily unavailable. How to solve this error There may be several ways to solve this error: Check whether the entered URL address is correct and make sure it is accessible Make sure the DNS server is available, you can try using the "ping" command on the command line to test whether the DNS server is available Try accessing the website using the IP address instead of the hostname if behind a proxy

Practical tips for converting full-width English letters into half-width form Practical tips for converting full-width English letters into half-width form Mar 26, 2024 am 09:54 AM

Practical tips for converting full-width English letters into half-width forms. In modern life, we often come into contact with English letters, and we often need to input English letters when using computers, mobile phones and other devices. However, sometimes we encounter full-width English letters, and we need to use the half-width form. So, how to convert full-width English letters to half-width form? Here are some practical tips for you. First of all, full-width English letters and numbers refer to characters that occupy a full-width position in the input method, while half-width English letters and numbers occupy a full-width position.

Detailed method to unblock using WeChat friend-assisted verification Detailed method to unblock using WeChat friend-assisted verification Mar 25, 2024 pm 01:26 PM

1. After opening WeChat, click the search icon, enter WeChat team, and click the service below to enter. 2. After entering, click the self-service tool option in the lower left corner. 3. After clicking, in the options above, click the option of unblocking/appealing for auxiliary verification.

PyCharm Beginner's Guide: Learn to Delete Projects in PyCharm PyCharm Beginner's Guide: Learn to Delete Projects in PyCharm Feb 23, 2024 pm 09:39 PM

PyCharm Beginner's Guide: Practical Tips for Deleting Projects PyCharm is a powerful Python integrated development environment (IDE). When developing projects, sometimes you need to delete projects or files in the projects. This article will introduce practical techniques for deleting projects in PyCharm, and provide specific code examples to help novices better understand and apply. 1. Delete the project Deleting the project means deleting the entire project folder, which is very useful when we need to clean or rebuild the project. Delete in PyCharm

The first choice for CS players: recommended computer configuration The first choice for CS players: recommended computer configuration Jan 02, 2024 pm 04:26 PM

1. Processor When choosing a computer configuration, the processor is one of the most important components. For playing games like CS, the performance of the processor directly affects the smoothness and response speed of the game. It is recommended to choose Intel Core i5 or i7 series processors because they have powerful multi-core processing capabilities and high frequencies, and can easily cope with the high requirements of CS. 2. Graphics card Graphics card is one of the important factors in game performance. For shooting games such as CS, the performance of the graphics card directly affects the clarity and smoothness of the game screen. It is recommended to choose NVIDIA GeForce GTX series or AMD Radeon RX series graphics cards. They have excellent graphics processing capabilities and high frame rate output, and can provide a better gaming experience. 3. Memory power

What is the difference between html and url What is the difference between html and url Mar 06, 2024 pm 03:06 PM

Differences: 1. Different definitions, url is a uniform resource locator, and html is a hypertext markup language; 2. There can be many urls in an html, but only one html page can exist in a url; 3. html refers to is a web page, and url refers to the website address.

See all articles