Use regular to remove annotation methods in PHP code _php instances

Source: Internet
Author: User
A regular expression is a syntax rule that describes the result of a string and is a specific formatting pattern that matches, replaces, and intercepts matching strings. Commonly used languages have regular expressions, such as JavaScript, Java, and so on. In fact, only by understanding the regular use of one language, the other language of the regular use, it is relatively simple. This article focuses on the use of regular code to remove the annotation method in PHP

Test code

File: A. Php

<?php/** * Addition calculation * Test *///set $ A value of $ A = 10;//set $b value $b = 5;//Add $c = $a + $b; # output echo $c;

Files: test.php

echo "Source: <br/>"; Show_source ('./a.php '); echo "

Test output

Execute test.php, output as follows:

Regular analysis

(\/\*.*\*\/)  Match/* */(#.*?\n)    Match #   after the first carriage return ended (\/\/.*?\n)  match//   end after the first carriage return is encountered

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.