What are the advantages of using the `preg_match` function in PHP for pattern matching over other methods?

When working with pattern matching in PHP, using the `preg_match` function provides more flexibility and power compared to other methods like `strpos` or `strstr`. `preg_match` allows you to use regular expressions to define complex patterns, making it easier to match specific strings or patterns within a larger string. This function also provides more control over the matching process, allowing you to capture specific parts of the matched string using capturing groups.

$pattern = '/\b(\w+)\b/';
$string = 'Hello, world!';

if (preg_match($pattern, $string, $matches)) {
    echo 'Match found: ' . $matches[0];
} else {
    echo 'No match found.';
}