我有這樣的內容,例如:正則表達式解析方法與參數
<?php echo $this->translate("Any text", "Any text next", "base-key") ?> Next string bla bla
string bla <?php echo $this->translate("SO Any text") ?>
enter code heretext bla <?php echo $this->translate("and string", null, "article-key") ?>
所以,我需要一個正則表達式的方法「翻譯」的第一和第三個參數匹配引號之間的文本。
輸出可能是這個樣子:
array (
array (
0 => Any text,
1 => base-key
),
array (
0 => SO Any text,
1 => null
),
array (
0 => and string,
1 => article-key
),
)
我想這樣表達:
/translate\(["\'](.*?)["\']/s
我剛剛得到的第一個參數字符串的方法 「翻譯」
告訴我們你的代碼負責正則表達式加工 –