What is a regular expression? His usage? What are his characteristics? (with detailed explanation)

慕斯
Release: 2023-03-10 12:44:02
Original
2608 people have browsed it

The previous article introduced you to "Reading file related operations after finishing the file operation in one day (with detailed explanation)". This article continues to introduce to you what is a regular expression? His usage? What are his characteristics? (With detailed explanation), let’s give it together and learn! ! !

What is a regular expression? His usage? What are his characteristics? (with detailed explanation)

#1: A brief introduction to regular expressions:

  • Regular expressions describe the string arrangement pattern A custom syntax rule

  • Don't use regular expressions if the task can be accomplished using string processing functions

  • There are some Complex operations can only be completed with regular expressions

  • Regular expression is also called a pattern expression

  • Regular expression The formula is to compare, split, match, search, and replace the input string information by constructing a pattern with specific rules.

2. What is Regular expression

Example:

 */<img\s+src=\" . *?\" V/>/" 它就是正则表达式
Copy after login

A bunch of messy characters piled together, mysterious symbols, with strange meanings.

3. Learn what regular expressions can do

  • #Verify whether the username length is legal.

  • Verify email rules

  • Verify mobile phone number

  • Verify URL

  • BBS Editor

  • ##QQ Chat Expression

  • ##News Collector, (Thief Program)
4: Look at several characteristics of regular expressions

    Regular expression is also a string
  • A string composed of characters with special meaning
  • has certain writing rules and is also a pattern
  • is regarded as A derogatory term for the language, because it uses some special characters to write a string according to the rules to form a pattern-regular expression
  • If the regular expression does not match the function When used together, it is just an ordinary string. Only if the regular expression is amplified and used in a function can the role of the regular expression be brought into play
5 . PHP provides two sets of regular expression function libraries

    posix extended regular expression ereg
  • perl compatible regular expression preg
  • It is recommended to use per1 compatible regular expression function library
6. When learning regular expressions, there are two aspects to learn .

    How to write regular expression patterns
  • Learn the powerful processing functions of regular expressions
7. The syntax of regular expressions

    Regular delimiters
  • In regular expressions Atoms
  • Metacharacters (atom modifiers) of regular expressions
  • Pattern modifiers of regular expressions
  • Recommended learning: "
PHP Video Tutorial

"

The above is the detailed content of What is a regular expression? His usage? What are his characteristics? (with detailed explanation). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!