2012-11-14 55 views
1

我試圖抓住PHP中使用preg_match_all的數組中的:""之間的字符串。php正則表達式之間的字符串:「和」

如:

"I am a string"("string"):"Need this string", "I am a string"("string"):"Need this string", etc, etc 

我有以下,但它不返回任何結果或錯誤而在正則表達式的建設者我試過的作品。

/\"\:"(.*?)\"/ and #/\"\:"(.*?)\"/# 

回答

1

表達可以由更簡單的是這樣的:

if (preg_match_all('/:"(.*?)"/', $str, $matches)) { 
    // $matches[1] will contain all the strings you want 
} 
+0

謝謝,這個工作 '/:"(.*?)"/' – brad

+0

是不正確的..表達式匹配字符串像「:」字符串「,」「adfadf」「'而不是」:「字符串」'' – vlcekmi3

+0

我似乎沒有得到這個問題? http://regexr.com?32q58 – brad

0

嘗試這種模式:

#:"([^"]*)"# 
相關問題