I'm trying to grab the string between :"
and "
in an array in PHP using preg_match_all.
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
}
试试这个模式:
#:"([^"]*)"#
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.