[Regular] why is this write effective?

Source: Internet
Author: User
[Regular] why is this write effective? This post was last written by php441914320 at 2012-12-1012:28:48 hours): I wrote this: ^w+.rar $ | ^ w+.zip $ | ^ w+.7z $ I, but later I found that this write can also be: invalid w+.rar | [regular] why does this write work?

This post was last edited by php441914320 at 12:28:48 on

Matching compressed package file name (x.rar x.rar x.7z ):

I wrote this:
'/^ \ W + \. rar $ | ^ \ w + \. zip $ | ^ \ w + \. 7z $/I'

But later I found that this write can also be:
'/^ \ W + \. rar | zip | 7z $/I'


The symbol "|" is not in place. please advise.

The second regular expression should be executed as follows:
For example, I have already named the compressed package test.rar"
The first match: “test.rar "is a failure.
Second match: it should match "zip", but why does it match "^ \ w + \. zip $ "?


------ Solution --------------------
It is best to read the file header information and check the file authenticity on the server side ~
Reference:
Reference: We recommend a function, pathinfo ();
PHP code? 1/^ \ w + \. (rar
------ Solution --------------------
Zip
------ Solution --------------------
7z) $/I
So there is no problem in writing it. o (character _ Blank) o haha.

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.