[英]php regex for string between :“ and ”
I'm trying to grab the string between :"
and "
in an array in PHP using preg_match_all. 我正在尝试使用preg_match_all在PHP数组中获取
:"
和"
之间的字符串。
eg: 例如:
"I am a string"("string"):"Need this string", "I am a string"("string"):"Need this string", etc, etc
I had the following but it returns no results or errors and works in the regex builders I've tried. 我有以下内容,但它不返回结果或错误,并且可以在我尝试过的正则表达式生成器中运行。
/\"\:"(.*?)\"/ and #/\"\:"(.*?)\"/#
The expression can be made much simpler like this: 这样可以使表达式更简单:
if (preg_match_all('/:"(.*?)"/', $str, $matches)) {
// $matches[1] will contain all the strings you want
}
试试这个模式:
#:"([^"]*)"#
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.