Php5 and mysql5 detailed explanation of web development technology-5 Regular Expressions

Source: Internet
Author: User

Regular Expression is a concise and flexible Expression for searching and replacing string patterns. It is not difficult to understand the importance. However, it is not easy to implement flexible applications without some practice. In php, there are two types of Regular Expressions: POSIX and PCRE. First, simply list the main content, and then add instructions and instances. I. POSIX (Portable Operating System Implementation for Unix), which means Unix can be transplanted to the Operating System Implementation interface. 1. ^ and $ locator 2. quantifiers or qualified words * +? {N} {n ,}{ n, m} 3. Square brackets expression [aAeEiIoOuU] character clusters of All vowels [0-9] [a-z] 4. predefined character clusters (built-in generic character clusters, specifies the processing range of characters.) [[: alpha:] uppercase/lowercase letters, same as [a-zA-Z] [[: digit:] digits, same as [0-9] [[: alnum:] uppercase and lowercase letters and numbers, same as [a-zA-Z0-9] [[: cntrl:] control characters, including Tab, return or backslash [[: space:] any white characters, including space, Tab, line feed, page feed, and carriage return ...... do not list them one by one 5. The Regular Expression Function ereg (condition, <original string>) eregi () is not case sensitive. ereg_replace (): ereg () adds the character replacement function eregi_replace () split () splits the string into arrays based on the Separator in the string form spliti () SQL _regcase () 6. POSIX Sub-Mode 2. PCRE (Perl Compatible Regular Expression) 1. Character cluster \ B \ d \ s \ t \ w 2. Use the separator/at the beginning and end of the matching expression. After the last separator, you can add modifiers I, M, S, X, U, and DU. You can also use various metacharacters, similar to POSIX locators and combinations of character clusters \ A, \ B, \ B, \ d, \ D, \ s, \ S, [], (), ^, $ ,., \, \ w, \ W 3, function www.2cto.com preg_match (): Example: preg_match ('/^ [[: alnum] {4, 8} $/', $ username) preg_match_all () preg_quote (): preg_split (): preg_grep () preg_replace (): replace preg_replace_callback ()

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.