Php regular expression matches a text string with 60 points. how can this problem be solved?

Source: Internet
Author: User
Php regular expression match a text paragraph is very simple 60 points PHPcode & lt; spanclass = & quot; ball-type-1 & quot; & gt; php regular expression match a text paragraph is very simple 60 points
PHP code
                                                                                  1                                                            2                                                            3                                                            4                                                            5                                                    


Match the numbers 1, 2, 3, 4, and 5.

Thanks for online refresh, etc.

------ Solution --------------------
$ Str = <


1

2

3

4

5


Html;
Preg_match_all ('# (.*)# IsU ', $ str, $ arr );
Print_r ($ arr [1]);
------ Solution --------------------
Preg_match_all ('# (\ D +)# IsU ', $ str, $ arr );
------ Solution --------------------
I: in-casesensitive, which is case insensitive.
S: PCRE_DOTALL, indicating that the DOT can match the line break.
U: PCRE_UNGREEDY, non-greedy, equivalent to. *? in perl/python .*?, During the matching process, if A. * regular expression matches, it is executed immediately, instead of waiting for. * to consume all characters and then one-to-one rollback.
------ Solution --------------------
PHP code
  1  2  3  4  5  html;preg_match_all('#(\d+)#i', $str, $arr);print_r($arr[1]);

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.