婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > 一個正則表達式的看法(?:)

一個正則表達式的看法(?:)

熱門標簽:上海銷售電銷機器人軟件 淄博市張店區地圖標注 山東外呼系統聯系方式 自己做的電銷機器人 浙江營銷外呼系統有哪些 惠安地圖標注 哈爾濱公司外呼系統代理 地圖標注店鋪地圖標注酒店 遼寧秒客來電話機器人
原正則的出現是為了實現apache上傳目錄無執行權限,不過大家知道在 windows下對于文件名是不區分大小寫的,但在*unx下就不同了,其中st0p.php和st0p.Php是兩個不同的文件,所以此正則(?i:.php)出現
復制代碼 代碼如下:

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

kindle說是參考http://perldoc.perl.org/perlre.html#Extended-Patterns的內容進行寫的,具體的內容大家自己看,我們說一下關于此表達式的部分..

我們找到?:相關的部分,其用法有兩種(?:pattern)和(?imsx-imsx:pattern)
我們需要用的是后者,前者的話是沒法區分大小寫的.而后者的用法就是(?標志修飾符:格式)
其中原文中有一句話是Any letters between ? and : act as flags modifiers as with (?imsx-imsx).
這句話就說明了imsx-imsx的作用,標志修飾符
我們看一下剛才出現的正則(?i:.php)
?的作用是在默認的貪婪模式下盡可能多的匹配所搜索的字符串,當該字符緊跟在任何一個其他限制符 (*, +, ?, {n}, {n,}, {n,m}) 后面時,匹配模式是非貪婪的。非貪婪模式盡可能少的匹配所搜索的字符串,例如,對于字符串 "oooo",'o+?' 將匹配單個 "o",而 'o+' 將匹配所有 'o'。

其中i的作用為忽略大小寫
.php就是我們需要匹配的部分,由于?和i的作用,那我們的正則就會在不區分大小寫的情況下盡可能多的匹配所搜索的字符串,這樣就達到了我們禁用所有.php后綴文件的訪問了

當然還有別的參數,更多的內容大家參考一下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.

其中:應該只是一個分隔符吧,不知道還有沒有別的作用,如果哪個大牛知道,請告訴我.

.php就是我們要匹配的部分了,從上面的圖我們..

標簽:宣城 泰州 長沙 銅川 西安 綿陽 無錫 重慶

巨人網絡通訊聲明:本文標題《一個正則表達式的看法(?:)》,本文關鍵詞  一個,正則,表達式,的,看法,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《一個正則表達式的看法(?:)》相關的同類信息!
  • 本頁收集關于一個正則表達式的看法(?:)的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 增城市| 南投县| 米林县| 当雄县| 吉首市| 莎车县| 嘉善县| 大新县| 江陵县| 西平县| 大新县| 襄汾县| 吉隆县| 台山市| 普兰店市| 澄江县| 乌鲁木齐市| 祁门县| 河南省| 绥中县| 阳原县| 曲麻莱县| 特克斯县| 施秉县| 旺苍县| 德兴市| 江山市| 蕲春县| 乐安县| 宁明县| 同德县| 闸北区| 精河县| 巴彦淖尔市| 东莞市| 乐至县| 延边| 蒲城县| 连云港市| 大新县| 鱼台县|