It's OK to put it in the online test tool, but it doesn't work with the echo array in the file.

Source: Internet
Author: User
This is the regular test tool that I can correctly match, why put to Preg_match_all ('/(\@[a-z]+\|[ \u4e00-\u9fa5]+\| [a-z]+\| [a-z]+\| [a-z]+\| [0-9]+)/is ', $a) is not good? Test tool Inside I choose the global search is OK, not select is not, is this the reason? Preg_match_all not a global search?


Reply to discussion (solution)

Several questions
1.preg_match_all (Regular, string, result), you have only two parameters above
2. Is your parameter split comma full-width?
3.\u changed into \x

/(\@[a-z]+\| [\u4e00-\u9fa5]+\| [a-z]+\| [a-z]+\| [a-z]+\| [0-9]+)/is U

Since you have Unicode characters in the rule string, you must have the U modifier

The correct wording is:
/(\@[a-z]+\| [\x{4e00}-\x{9fa5}]+\| [a-z]+\| [a-z]+\| [a-z]+\| [0-9]+]/isu

The correct wording is:
/(\@[a-z]+\| [\x{4e00}-\x{9fa5}]+\| [a-z]+\| [a-z]+\| [a-z]+\| [0-9]+]/isu
Why the final result $res (the third argument) is a two-dimensional array with two elements, and the contents of the two elements are the same?
$res [0] $res [1]

The correct wording is:
/(\@[a-z]+\| [\x{4e00}-\x{9fa5}]+\| [a-z]+\| [a-z]+\| [a-z]+\| [0-9]+]/isu
Thank you for the results. Already, ask, why I before those online test tools inside test this rule, can get the correct match, put in the file is not allowed?
@[a-z]+\| [\u4e00-\u9fa5]+\| [a-z]+\| [a-z]+\| [a-z]+\| [0-9]+

This \u4e00-\u9fa5 is a Unicode-encoded Chinese section, so you can see that your test tool is in the form of a Web page.
The regular engine of PHP does not recognize this format, and naturally it will not get the correct results.


The correct wording is:
/(\@[a-z]+\| [\x{4e00}-\x{9fa5}]+\| [a-z]+\| [a-z]+\| [a-z]+\| [0-9]+]/isu
Thank you for the results. Already, ask, why I before those online test tools inside test this rule, can get the correct match, put in the file is not allowed?
@[a-z]+\| [\u4e00-\u9fa5]+\| [a-z]+\| [a-z]+\| [a-z]+\| [0-9]+
The online test or browser plugin is not PHP engine, may be the JS engine inside the regular

  • Related Article

    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.