我讨厌preg_match语法!
[file.txt]来源:
sth = s("Would you like to go to the cinema "+
"With me?");
}
else if (something)
{
sth = s("Would you like to go to the cinema "+
"With me?");
} else {
sth = s("Sure, no problem");
}
PHP:
$file = file_get_contents("file.txt");
$file = str_replace(PHP_EOL, '', $file);
preg_match_all("/s'('"(.*) /", $file, $matches);
var_dump($matches);
这显示了太多的单词,因为我有"起点",没有结束模式。但我不知道,我怎么能用这样的结尾delimeter创建preg:
preg_match("/ [s(" .... ")] /")
我想从来源提取:
"Would you like to go to the cinema With me?"
"Would you like to go to the cinema With me?"
"Sure, no problem"
请帮我创建图案。
你可以试试这个,
$regex = "/s''('''"(.*?)'''"'');/s";
并从输出中替换CCD_ 3和CCD_
演示