The view of a regular expression (?:) _ Regular expression

Source: Internet
Author: User
Tags locale modifiers
Huare is to achieve the Apache upload directory without executive permission, but you know that in Windows for file names are case-insensitive, but under *unx is different, where st0p.php and st0p.php are two different files, so this regular (? i:.php) Appear
Copy Code code as follows:

<directory "/var/www/upload" >
<filesmatch "(? i:.php)" >
Order Allow,deny
Deny from all
</FilesMatch>
</Directory>

The Kindle says it is written in reference to the content of the http://perldoc.perl.org/perlre.html, the specific content that everybody sees, let's talk about the part about this expression.

We found it.: The related part, its use has two kinds (?:p Attern) and (? imsx-imsx:pattern)
We need to use the latter, the former words can not be case-sensitive. And the latter usage is (? flag modifiers: Format)
There is a word in the original which is any letters between? And:act as flags modifiers as with (? IMSX-IMSX).
This statement explains the role of IMSX-IMSX, the flag modifier
Let's take a look at the regular (? i:.php) that just appeared.
The role is to match the search string as much as possible in the default greedy mode, and when the character is followed by any of the other qualifiers (*, +,?, {n}, {n,}, {n,m}), the matching pattern is not greedy. Non-greedy patterns match as few of the searched strings as possible, for example, for the string "oooo", ' o+? ' will match a single "O", and ' o+ ' will match all ' o '.

The effect of I is to ignore the case
. PHP is the part that we need to match, and because of the role of? And I, our regular will match the search string as much as possible without case sensitivity, so that we have access to disable all. php suffix files.

Of course, there are other parameters, more content you refer to http://perldoc.perl.org/perlre.html

M
Treat string as multiple lines. It, change "^" and "$" from matching the "start" or "the", "the", "the", "the", "the" Start or " Within the string.

S
Treat string as single. It, change "." to match any character whatsoever, even a newline, which normally it would not match.
Used together, As/ms, they let the "." Match any character whatsoever, while still allowing "^" and "$" to match, respect Ively, just after and just before newlines the string.

I
Do case-insensitive pattern matching.
If use locale's in effect, the case map is taken to the current locale. Perllocale.

X
Extend your pattern ' s legibility by permitting whitespace and comments.

P
Preserve the string matched such that ${^prematch}, ${^match}, and ${^postmatch} are available for use after matching.

G and C
Global matching, and keep the current position after failed matching. Unlike I, M, s and X, these two flags affect the way of the regex is used rather the regex than. "Using Regular Expressions in Perl" in Perlretut for further explanation of the G and C modifiers.

Among them: should be just a separator bar, do not know whether there is no other role, if any Daniel know, please tell me.

. PHP is the part we want to match, from the above figure we ...

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.