Function: preg_match_all ()

Source: Internet
Author: User
Function: preg_match_all () function: preg_match_all ()

--------------------------------------------------------------------------------



Perl Compatible syntax Library





Preg_match_all
String comparison analysis.



Syntax: int preg_match_all (string pattern, string subject, array matches, int [order]);



Return value: integer



Correspondence type: data processing









Description





This function uses the pattern rule to analyze the comparison string subject as a whole. The values returned from the comparison are placed in the array parameter matches and sorted by order. The value of 'order' can be PREG_PATTERN_ORDER or PREG_SET_ORDER. If there is no order value, the system automatically uses PREG_PATTERN_ORDER to place it in the order value. The return value is the number of matching results. if there is no or an error occurs, the return value is false.









Example





Example of PREG_PATTERN_ORDER




Preg_match_all ("| <[^>] +> (.*) ] +> | U ","

A test

", $ Out, PREG_PATTERN_ORDER );

Print $ out [0] [0]. ",". $ out [0] [1]. "\ n ";

Print $ out [1] [0]. ",". $ out [1] [1]. "\ n"

?>



The return value is



Example:,

This is a test



Example:, this is a test









Example of PREG_SET_ORDER




Preg_match_all ("| <[^>] +> (.*) ] +> | U ","

A test

", $ Out, PREG_SET_ORDER );

Print $ out [0] [0]. ",". $ out [0] [1]. "\ n ";

Print $ out [1] [0]. ",". $ out [1] [1]. "\ n"

?>



The return value is



Example:, Example:

This is a test

, This is a test


<

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.