Php regular expression matching function body_php skills

Source: Internet
Author: User
Tags php regular expression
Take PHP as an example. Other languages are similar. The code is as follows:


$ Data = php_strip_whitespace ('test. php'); // remove comments, spaces, and line breaks (excluding strings)
Echo $ data;
$ Data = preg_match_all ("
/
Function \ s + # Match function and space
[A-zA-Z _ \ x7f-\ xff] [a-zA-Z0-9 _ \ x7f-\ xff] * # matching function name
\ ([^)] *?) \) \ S + # Match function parameters and capture them as sub-modes
\{
(.*?)
\}(? = (? : \ S * function | \ s *? $) # Matching braces, only when followed by the function or at the end of the string
/Xi
", $ Data, $ matches );

Print_r ($ matches );
?>

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.