PHP Regular Expression Learning notes ____php

Source: Internet
Author: User
Tags php regular expression

Preg_match regular functions, based on the Perl language

Preg_match (mode, string subject, array matches)

Elements included in the regular expression

(1), Atomic (ordinary character: A-Z-A-Z 0-9, Atomic table, escape character)
(2), metacharacters (with special function characters)
(3), pattern modifier (System built-in part of the characters I, M, S, U ...) )

"Atoms" in regular expressions

①a-z-A-Z _ 0-9  ///most common character
② (ABC) (SKD)  ///with parentheses included units in accordance with
③[abcs] [^ABD]//with square brackets containing atomic tables, and ^ in atomic tables excluding or opposing content
④ escape character
  \d  contains all numbers [0-9]
  \d  except all numbers [^0-9]
  \w  contains all English characters [a-za-z_0-9]
  \w  Except for all English characters [^a-za-z_0-9]?  \s   contains blank areas such as carriage return, line break, paging, etc. [\f\n\r]

Regular expression meta-characters

*  matches the previous 0 times 1 or more times
.  Matches the content 0 times 1 or more times, but does not contain a carriage return line
+ match 1 or more times before the previous content
. 0 or 1 times to match previous content
|  Select match similar to PHP | (because this operation conforms to a weak type leading to the most overall match)
^  Match string Header content
$  Match string tail content
\b Match word boundary, boundary can be a space or special match
\b Match exception with Word boundary unexpected content
{m} matches the previous content with a repeat number of M times
{m,} matches the previous content of the repeat number of times greater than equal
to M {m,n} matches the previous content of the repeat number of times M to N times
() merge the whole match, And put in memory, you can use \1 \2 ... Sequentially get

Appendix: Full symbolic interpretation of regular expressions
Http://www.cnblogs.com/yirlin/archive/2006/04/12/373222.html

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.