What is a regular expression (? :)

Source: Internet
Author: User

The original regular expression is used to enable the apache upload directory to have no execution permission. However, in windows, the file name is case-insensitive, but it is different in * unx, where st0p. php and st0p. php is two different files, so this regular (? I:. php) appears Copy codeThe Code is as follows: <Directory "/var/www/upload">
<FilesMatch "(? I:. php) ">
Order Allow, Deny
Deny from all
</FilesMatch>
</Directory>

Please refer to kindle for more information ..

We found? : The related part, which can be used in two ways (? : Pattern) and (? Imsx-imsx: pattern)
We need to use the latter. The former cannot be case sensitive, while the latter uses (? Flag modifier: Format)
Which of the following statements in the original text is Any letters? And: act as flags modifiers as (? Imsx-imsx ).
This statement illustrates the role of imsx-imsx, a flag modifier.
Let's take a look at the regular expression (? I:. php)
? The function is to match as many searched strings as possible in the default greedy mode. When the character follows any other delimiter (*, + ,?, The matching mode after {n}, {n ,}, {n, m}) is not greedy. The non-Greedy mode matches as few searched strings as possible, for example, for strings "oooo", 'O ++? 'Will match a single "o", and 'O +' will match all 'O '.

I is used to ignore case sensitivity.
. Php is the part we need to match, because? And I, then our regular expression will match as many strings as possible without case sensitivity, so that we can disable all. php suffix File Access

Of course there are other parameters, more content for your reference http://perldoc.perl.org/perlre.html#Extended-Patterns

M
Treat string as multiple lines. That is, change "^" and "$" from matching the start or end of the string to matching the start or end of any line anywhere within the string.

S
Treat string as single line. That is, change "." to match any character whatsoever, even a newline, which normally it wocould not match.
Used together, as/MS, they let ". "match any character whatsoever, while still allowing" ^ "and" $ "to match, respectively, just after and just before newlines within the string.

I
Do case-insensitive pattern matching.
If use locale is in effect, the case map is taken from the current locale. See 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 the regex is used rather than the regex itself. see "Using regular expressions in Perl" in perlretut for further explanation of the g and c modifiers.

Here: it should be just a separator. I don't know if it has any other functions. If any Daniel knows, please let me know.

. 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.