1

我正在尝试使用 preg_match_all 在 PHP 中的数组之间:"和数组中获取字符串。"

例如:

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

我有以下内容,但它没有返回任何结果或错误,并且在我尝试过的正则表达式构建器中工作。

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

2 回答 2

1

表达式可以变得更简单,如下所示:

if (preg_match_all('/:"(.*?)"/', $str, $matches)) {
    // $matches[1] will contain all the strings you want
}
于 2012-11-14T10:49:00.510 回答
0

试试这个模式:

#:"([^"]*)"#
于 2012-11-14T10:43:10.160 回答