Exploring PHP regular expression implementation information record _ PHP Tutorial

Source: Internet
Author: User
Tags php regular expression
Explore PHP regular expression implementation information record. When using PHP regular expressions, have we noticed how we operate when we need to record information? So here we will introduce you to PHP regular expressions to implement information record. when we use PHP regular expressions, have you noticed how we operate when we need to record information? Here we will introduce you to the specific methods for implementing information record in PHP regular expressions, and hope to help you.

In fact, during the development of PHP regular expressions, one character is specifically used to implement information record. this is the Bracket "()", which is so amazing, how is it done?

The PHP regular expression parses information records:

In addition to user matching, PHP regular expressions can also use parentheses () to record the required information, store it, and read the subsequent expressions.

PHP regular expression for information record instance and analysis:

 
 
  1. /^([a-zA-Z0-9_-]+)@([a-zA-Z0-9_-]+)(.[a-zA-Z0-9_-])$/

The above PHP regular expression implementation information record instance is to record the mail address username, and mail address server address (in the form of username@server.com and so on), in the following if you want to read the recorded string, you only need to use the "escape character + record order" to read. For example, "\ 1" is equivalent to the first "[a-zA-Z0-9 _-] +", "\ 2" is equivalent to the second ([a-zA-Z0-9 _-] + ), "\ 3" is the third (. [a-zA-Z0-9 _-]). However, in PHP, "" is a special character and needs to be escaped. Therefore, "1" should be written as "\ 1" in the PHP expression ".

In addition, we also pay attention to a special symbol of the PHP regular expression:

"|": Or symbol "|" is the same as or in PHP, but it is a "|" instead of two "| "! It can be a character or another string, for example, "/abcd | dcba/" may match "abcd" or "dcba ".

The PHP regular expression implements information record-related content and will be introduced to you here, hoping to help you understand and use PHP regular expressions.


Why? So here we will introduce you to the PHP regular expression implementation information record...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.