2012-11-14 57 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

尝试这种模式:

#:"([^"]*)"# 
相关问题