Suppose you want to get content using preg_match function for specific div class name or id. This is HTML

<div class="calss1 class2 class3">
    Content 1
</div>
<div class="class1 class2 class3">
    Content 2
</div>
<div class="class1 class2 class3">
    Content 3
</div>
<div class="class1 class2 class3">
    Content 4
</div>
<div class="class1 class2 class3">
    Content 5
</div>

then you want to get content using specific class name , not all class name like class name class1

then you can use this code which get all content which class name first class1

 if (preg_match('/<div class="class1(\s.*?)?">(.*?)<\/div>/is', $my_content, $result)) {
            print_r($result);
        }

This will get all result which you want, if you face any problem then please inform me.