Home Backend Development PHP Tutorial php URL验证正则表达式_php技巧

php URL验证正则表达式_php技巧

May 17, 2016 am 09:16 AM
url verification

复制代码 代码如下:

$url = 'http://www.baidu.com/zongzi/oo.html';
$n = preg_match_all("/http:[\/]{2}[a-z]+[.]{1}[a-z\d\-]+[.]{1}[a-z\d]*[\/]*[A-Za-z\d]*[\/]*[A-Za-z\d]*[.]*html/",$url,$array);
var_dump($array);
?>
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)

Hot Topics

Java Tutorial
1653
14
PHP Tutorial
1251
29
C# Tutorial
1224
24
How to verify if a URL contains a specified string using regular expressions in PHP How to verify if a URL contains a specified string using regular expressions in PHP Jun 24, 2023 am 09:39 AM

With the development of the Internet, URLs have become an integral part of people's daily lives. Sometimes, we need to validate a URL to determine if it contains a specific string. In PHP, you can use regular expressions to perform this process. This article will introduce how to use regular expressions to verify whether a URL contains a specified string in PHP. First, we need to understand some basic concepts in regular expressions. Regular expressions are expressions used to match string patterns. It is a special syntax used in patterns

How to use regular expressions to verify URL addresses in golang How to use regular expressions to verify URL addresses in golang Jun 24, 2023 pm 04:00 PM

In recent years, with the rapid development of the Internet, our lives are increasingly inseparable from the Internet. When we use the Internet, we often need to enter or provide a URL address. In order to ensure security and accuracy, we need to verify the entered URL address. This article will introduce how to use regular expressions in golang to verify URL addresses. Basic components of a URL address A standard URL address contains the following parts: Protocol: such as http, https, ftp, etc. domain name

How to use regular expressions in golang to verify whether the URL address is a second-level domain name How to use regular expressions in golang to verify whether the URL address is a second-level domain name Jun 25, 2023 pm 06:30 PM

It is a common requirement in golang to use regular expressions to verify whether the URL address is a second-level domain name. In this article, we will introduce how to use regular expressions in golang for verification, and how to write regular expressions to verify whether a URL address is a second-level domain name. First, let's take a look at the basic usage of regular expressions in golang. Golang provides a regular expression library regexp. We can use regular expressions by calling the regexp package. Using regular tables

How to use regular expressions in golang to verify whether the URL address is a fifth-level domain name How to use regular expressions in golang to verify whether the URL address is a fifth-level domain name Jun 24, 2023 am 08:36 AM

Using regular expressions in golang to verify whether a URL address is a fifth-level domain name can be achieved through the following steps: First, we need to understand what a fifth-level domain name is, which refers to a complete domain name consisting of 5 parts, for example: https ://www.example.com.cn, the five parts are: protocol, host name, second-level domain name, third-level domain name and top-level domain name. In this article, we will verify whether a URL address is in the format of a fifth-level domain name. Next, we need to understand

How to use regular expressions in golang to verify whether the URL address is a first-level domain name How to use regular expressions in golang to verify whether the URL address is a first-level domain name Jun 24, 2023 am 11:19 AM

In golang, it is very simple to use regular expressions to verify first-level domain names. First, we need to understand what a first-level domain name is. The first-level domain name refers to the highest-level domain name among Internet domain names, usually consisting of one word or abbreviation. For example, com in google.com is the first-level domain name. Therefore, the URL address we want to verify should be in a format similar to www.google.com or abc.baidu.com. Next, we can use golang’s regular

How to validate input of URL parameters using regular expressions in PHP How to validate input of URL parameters using regular expressions in PHP Jun 24, 2023 am 11:10 AM

In web development, the input of URL parameters is very common. It is usually used to pass parameters to the server in order to perform some specific operations or query data. However, since input of URL parameters is not restricted, malicious users can exploit inappropriate input to attack your application. Therefore, validating the input of URL parameters is crucial. In this article, we will cover how to use regular expressions in PHP to validate input of URL parameters. First we need to understand what regular expressions are. Regular expression is a type of word used to match

How to use regular expressions in golang to verify whether the input is a complete URL address How to use regular expressions in golang to verify whether the input is a complete URL address Jun 24, 2023 pm 01:30 PM

In golang, it is very important to use regular expressions to verify whether an input is a complete URL address. Regular expressions are a descriptive language that can be used to match text patterns in strings. When we need to verify whether an input conforms to a certain format, regular expressions can help us quickly determine whether the input is correct. So how to use regular expressions in golang to verify whether the input is a complete URL address? This article will explain it to you. First, we need to understand the base of a URL address

Java Security: How to Prevent Insecure URL Redirects Java Security: How to Prevent Insecure URL Redirects Jun 29, 2023 pm 07:40 PM

Java Security: How to Prevent Insecure URL Redirects Introduction: In the modern Internet environment, URL redirections have become a common feature in web applications. It allows users to be sent to another URL when they click on a link, which facilitates user navigation and experience. However, URL redirection also brings some security risks, such as malicious redirection attacks. This article will focus on how to prevent unsafe URL redirections in Java applications. 1. Risks of URL redirection: The main reason why URL redirection is abused is that it

See all articles