看板 PHP 關於我們 聯絡資訊
※ 引述《fillmore (.......................)》之銘言: : ※ 引述《fillmore (.......................)》之銘言: : : 我用的是'/([^"]+)[\\]/'單引號括會錯=> missing terminating] for character class : : 但是'/([^"]+)[\\\\]/' 這樣就沒錯 : : 不知道為什麼? : 例子 : window.location=\'http://test.orz/download.php?session=25586136a8\' : 這樣寫是正確=> '/http:\/\/test.orz\/download.php[?]session[=]([^"]+)[\\\\]/' : 但是 [\\\\] 改成 [\\] 卻是錯誤 我錯了Orz 單引號只會處理\\和\'而已 其他不會處理 所以\還是得寫四個 -- 'Oh, Harry, dont't you see?' Hermione breathed. 'If she could have done one thing to make absolutely sure that every single person in this school will read your interview, it was banning it!' ---'Harry Potter and the order of the phoenix', P513 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 192.192.197.115
foxzgerald:我還是轉不過來 = =" 可以解釋一下嗎? 06/28 20:26
LPH66:單引號的escape sequence只處理\\和\' 06/29 05:41
LPH66:所以當你需要一個字串內含兩個反斜線時一定要打四個 06/29 05:41
LPH66:這樣處理出來才是一個含有兩個反斜線的字串 06/29 05:42
fillmore:總之單引號要辨別\\字串就要打\\\\四個 06/29 09:20
buganini:一層給PHP parser看,另一層給PCRE parser看 07/02 20:18