Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the use of PHP regular expressions?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the use of PHP regular expressions, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

PHP is a commonly used scripting language for writing dynamic WEB page development, and regular expressions are a very important part of PHP. Let's talk about PHP regular expressions in detail. In ASP and ColdFusion, users can mix PHP and HTML to write WEB pages. When visitors browse to the page, the server will first process the PHP commands in the page, and then transmit the processed results to the browser of the visiting side together with the HTML content.

A detailed introduction to the conversion from PHP array to string

Detailed explanation of the assignment method of simple and Fast PHP Array

The basic PHP operator summary treasure book

Using built-in functions to solve the sorting problem of PHP Multi-dimensional arrays

Play with PHP numeric function

But unlike ASP or ColdFusion, PHP is an open source program with good cross-platform compatibility. Users can run PHP on Windows NT systems and many versions of Unix systems, and PHP can be run as a built-in module or CGI program in the Apache server. In addition to precisely controlling the display of WEB pages, users can also send HTTP headers using PHP. Users can set cookies through PHP, manage user identity, and redirect users to browse the page. PHP has a very powerful database support function, which can access almost all the popular database systems at present. In addition, PHP can be integrated with multiple external libraries to provide users with more practical functions, such as generating PDF files. Although many people are familiar with PHP regular expressions, as an important basic part, notes can not be avoided.

Introduction to PHP regular expressions:

1. Square bracket

[0-9] match 0-9 [Amurz] match Amurz lowercase letter [Amurz] match Amurz uppercase letter [a-zA-Z] match all uppercase and lowercase letters can use ascii to make more

two。 Quantifier

P + matches at least one string p * containing p to accompany any string p containing 0 or more p? Match any string p {2} containing 0 or one p match string p {2} containing sequence of 2 p match any string containing 2 or 3 p match any string ending with p ^ p match any string that begins with p [^ a-zA-Z] match any string that does not contain a-zA-Z match any string that contains p, followed by any character, Then there is the string ^. {2} $which is p again. {2} $matches any string whose value contains 2 characters (. *) b > matches any string p (hp) * that is surrounded by >. Matches any string that contains p. Followed by multiple or 0 hp strings

3. Predefined character range

[: alpha:] matches [a-zA-Z] [: alnum:] with [a-zA-Z0-9] [: cntrl:] to match control characters, such as tabs, backslashes, backspace [: digit:] with [0-9] [: graph:] all characters that can be printed within the ASCII33~166 range [: lower:] with [Amurz] [: punct:] punctuation [: upper:] with [upper Z] [: space:] white space characters Can be space, horizontal tab, line feed, page feed, enter [: xdigit:] hexadecimal character with [a-fA-F0-9]

4.ereg statements can be judged by case sensitivity, as shown in the following example

If (ereg ("([^ amurz])", "aaaaZaaaaaaa")) echo "is not all lowercase!"

Ereg can also return an array such as

$url= "http://www.xuandun.net"; $a=ereg (" ^ (http://www)\.([[:alnum:]]+)\.([[:alnum:]]+)",$url,$regs); echo $regs [0], "

"; echo $regs [1],"

"; echo $regs [2],"

"; echo $regs [3],"

"

Get

Http://www.xuandun.net http://www xuandun net thank you for reading this article carefully. I hope the article "what's the use of PHP regular expressions" shared by the editor will be helpful to you? at the same time, I also hope you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report