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:
- /^([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...