$re = '/.*Summer.*/';
$str = '_id": ObjectId("001"),
"searchkey": "Test Product Test Product T-shirt Half sleeves Adidas"
}
{
"_id": ObjectId("123"),
"searchkey": "boy test Product Test Product T-shirt Half sleeves Nike"
}
{
"_id": ObjectId("456"),
"searchkey": "girl test Product Summer Product T-shirt full sleeves Adidas"
}
{
"_id": ObjectId("789"),
"searchkey": "any product any Product any Product T-shirt full sleeves Adidas"
}
{
"_id": ObjectId("1010"),
"searchkey": "woodland Product woodland Product T-shirt Half sleeves woodland"
}
{
"_id": ObjectId("1212"),
"searchkey": "Summer Product Test Product T-shirt Half sleeves Adidas';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php