一個(gè)正則表達(dá)式的看法(?:)
<Directory "/var/www/upload">
<FilesMatch "(?i:.php)">
Order Allow,Deny
Deny from all
</FilesMatch>
</Directory>
kindle說(shuō)是參考http://perldoc.perl.org/perlre.html#Extended-Patterns的內(nèi)容進(jìn)行寫(xiě)的,具體的內(nèi)容大家自己看,我們說(shuō)一下關(guān)于此表達(dá)式的部分..
我們找到?:相關(guān)的部分,其用法有兩種(?:pattern)和(?imsx-imsx:pattern)
我們需要用的是后者,前者的話是沒(méi)法區(qū)分大小寫(xiě)的.而后者的用法就是(?標(biāo)志修飾符:格式)
其中原文中有一句話是Any letters between ? and : act as flags modifiers as with (?imsx-imsx).
這句話就說(shuō)明了imsx-imsx的作用,標(biāo)志修飾符
我們看一下剛才出現(xiàn)的正則(?i:.php)
?的作用是在默認(rèn)的貪婪模式下盡可能多的匹配所搜索的字符串,當(dāng)該字符緊跟在任何一個(gè)其他限制符 (*, +, ?, {n}, {n,}, {n,m}) 后面時(shí),匹配模式是非貪婪的。非貪婪模式盡可能少的匹配所搜索的字符串,例如,對(duì)于字符串 "oooo",'o+?' 將匹配單個(gè) "o",而 'o+' 將匹配所有 'o'。
其中i的作用為忽略大小寫(xiě)
.php就是我們需要匹配的部分,由于?和i的作用,那我們的正則就會(huì)在不區(qū)分大小寫(xiě)的情況下盡可能多的匹配所搜索的字符串,這樣就達(dá)到了我們禁用所有.php后綴文件的訪問(wèn)了
當(dāng)然還有別的參數(shù),更多的內(nèi)容大家參考一下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 would not match.
Used together, as /ms, they let the "." 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.
其中:應(yīng)該只是一個(gè)分隔符吧,不知道還有沒(méi)有別的作用,如果哪個(gè)大牛知道,請(qǐng)告訴我.
.php就是我們要匹配的部分了,從上面的圖我們..
相關(guān)文章
校驗(yàn)普通電話、傳真號(hào)碼的正則表達(dá)式(可以+開(kāi)頭,除數(shù)字外,可含有-)
校驗(yàn)普通電話、傳真號(hào)碼:可以“+”開(kāi)頭,除數(shù)字外,可含有“-”2010-10-10正則表達(dá)式之字符組簡(jiǎn)記法與字符組運(yùn)算
這篇文章主要介紹了正則表達(dá)式之字符組簡(jiǎn)記法與字符組運(yùn)算,用[0-9]、[a-z]等字符組,這里就為大家介紹一下,需要的朋友可以參考下2023-05-05shell腳本之正則表達(dá)式、grep、sed、awk
這篇文章主要介紹了shell腳本之正則表達(dá)式、grep、sed、awk的相關(guān)知識(shí),非常不錯(cuò),具有一定的參考借鑒價(jià)值 ,需要的朋友可以參考下2019-04-04正則表達(dá)式實(shí)現(xiàn)與或非關(guān)系【推薦】
這篇文章主要介紹了正則表達(dá)式實(shí)現(xiàn)與或非關(guān)系,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-07-07通過(guò)Java正則表達(dá)式去掉SQL代碼中回車(chē)換行和多余空格
剛才在寫(xiě)一個(gè)代碼工具,遇到SQL換行和多余空格的問(wèn)題,導(dǎo)致處理很困難,于是寫(xiě)了一個(gè)正則式,搞定了,特分享下方便需要的朋友2012-09-09