Home>Article>Backend Development> What is a regular expression? His usage? What are his characteristics? (with detailed explanation)

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

慕斯
慕斯 Original
2021-06-08 17:55:15 2567browse

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:

*//" 它就是正则表达式

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!

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