簡體   English   中英

php regex用於:“和”之間的字符串

[英]php regex for string between :“ and ”

我正在嘗試使用preg_match_all在PHP數組中獲取:""之間的字符串。

例如:

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

我有以下內容,但它不返回結果或錯誤,並且可以在我嘗試過的正則表達式生成器中運行。

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

這樣可以使表達式更簡單:

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

試試這個模式:

#:"([^"]*)"#

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM