Preg_match在一个单词后面和另一个单词之后查找单词


Preg_match find word after a word and after another word

我正在尝试使用preg_match获取字符串中的单词数组。。CCD_ 1和CCD_。

$content= 'class="gametitle WORD1">< ggg class="userid">WORD2 </ gg>';

我想要WORD1WORD2

现在我只能得到单词1

$prematch=preg_match('/.class="gametitle.(.*)".*/isU', $content, $matches);
echo $matches[1];

提前thx!

if (preg_match_all('/class's?='s?"gametitle's+('w+)"><[^>]+>'s?('w+)/', $text, $matches)){
    $word1 = $matches[1][0];
    $word2 = $matches[2][0];
}

或使用preg_match:

if (preg_match('/class's?='s?"gametitle's+('w+)"><[^>]+>'s?('w+)/', $text, $matches)){
    $word1 = $matches[1];
    $word2 = $matches[2];
}