PHP5 and MYSQL5 Web development technology-5 regular Expressions _php tutorial

Source: Internet
Author: User
Tags control characters ereg posix
Regular Expressions (Regular expression) are concise and flexible representations of the find and replace string patterns. Importance is no longer mentioned, it is not difficult to understand, but without certain practice, it is not easy to apply flexibly. In PHP, there are two types of regular expressions for POSIX and pcre. First, simply list out the main content, and then add a description and examples. One, POSIX (Portable Operating System implementation for UNIX), which means implementing interfaces for UNIX portable operating systems. 1, ^ and $ locator 2, quantifier or qualifier * +? {n} {N,} {n,m}3, bracket expression [aaeeiioouu] character clusters for all vowel characters [0-9] [a-z]4, predefined character clusters (built-in universal character cluster, specified character processing range) [[: Alpha:]] uppercase and lowercase letters, with [a-za-z] [[: Digit:]] numbers, with [0-9] [[: Alnum:]] uppercase and lowercase letters and numbers, with [a-za-z0-9] [[: Cntrl:]] control characters, including Tab, backspace, or backslash [[: space:]] any white characters, including spaces, tabs, line breaks, Page change and carriage return ... Do not enumerate 5, the regular expression function ereg (condition, <原始字符串> ) eregi () is not case-sensitive ereg_replace (): Ereg () is added on the basis of the character substitution function eregi_replace () split () for delimiter pairs in a string split array form Spliti () sql_regcase () 6, POSIX sub-mode two, PCRE (Perl Compatible Regular expression) 1, character cluster \\b \\d \\s \\t \\w 2, match expression start and end use delimiter/, last delimiter/after, can add adornments Characters I, M, S,x,u,du can also use a variety of meta-characters, such as POSIX-like locators and a combination 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 () : Add the Italian character preg_split (): Preg_grep () preg_replace (): Replace Preg_replace_callback ()

http://www.bkjia.com/PHPjc/477713.html www.bkjia.com true http://www.bkjia.com/PHPjc/477713.html techarticle Regular Expressions (Regular expression) are concise and flexible representations of the find and replace string patterns. Importance is no longer mentioned, it is not difficult to understand, but if there is no certain practice, do ...

  • 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.