How can PHP developers ensure that preg_match searches for partial matches of a string rather than exact matches?

To search for partial matches of a string rather than exact matches using preg_match in PHP, developers can use the regex pattern with the appropriate wildcards to allow for partial matches. By using the wildcard characters like .* before and after the search term, the regex pattern will match any characters before and after the search term, enabling partial matching.

$string = "Hello, World!";
$searchTerm = "lo";

if (preg_match("/.*" . $searchTerm . ".*/", $string)) {
    echo "Partial match found!";
} else {
    echo "No partial match found.";
}